The ChartPanel class overrides paintComponent(Graphics) and casts the incoming Graphics object the Graphics2D subclass - this is very common in Swing apps as a way to gain access to Java2D features for drawing on Swing components. I'm almost certain that the Graphics object is guaranteed to be a Graphics2D instance, and the original method signature is maintained for backwards compatibility only, although this isn't mentioned in the API specification. The only reference I've been able to find is this one in the Java tutorial: http://java.sun.com/docs/books/tutorial/uiswing/14painting/practice.html I think many applications are going to fail on our implementation until we get good Graphics2D support into our JComponent (many custom look and feel implementations rely on it, for starters). Regards, Dave Audrius Meskauskas wrote: > This is because jMemorize overrides the JTable.columnMarginChanged > that is fired from the JTable constructor, when the user - derived > class is not yet initialised. This can be easily fixed by initialising > the table column model befor the table listeners are installed on it, > I have comitted such patch. Unfortunately, this brings us to the > second exception, related to the JFreeChart: > > java.lang.ClassCastException: gnu/java/awt/peer/gtk/GdkGraphics > at org.jfree.chart.ChartPanel.paintComponent (ChartPanel.java:905) > at javax.swing.JComponent.paint (JComponent.java:1583) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JSplitPane.paintChildren (JSplitPane.java:538) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JSplitPane.paintChildren (JSplitPane.java:538) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > at javax.swing.JComponent.paint (JComponent.java:1585) > at javax.swing.JLayeredPane.paint (JLayeredPane.java:647) > at javax.swing.JComponent.paintChildren (JComponent.java:1700) > > Probably our JFreeChart experts could look at this. > > Regards > Audrius. > > Robert Schuster wrote: > >> Hi, >> I added jMemorize[0] to the list of Free Swing apps. I just stumbled >> over the >> app and tried to run it but it fails with a NPE: >> >> java.lang.reflect.InvocationTargetException >> at java.lang.reflect.Method.invokeNative (Native Method) >> at java.lang.reflect.Method.invoke (Method.java:355) >> at jamvm.java.lang.JarLauncher.main (JarLauncher.java:50) >> Caused by: java.lang.NullPointerException >> at jmemorize.gui.swing.CardTable.columnMarginChanged (Unknown Source) >> at javax.swing.table.DefaultTableColumnModel.fireColumnMarginChanged >> (DefaultTableColumnModel.java:493) >> at javax.swing.table.DefaultTableColumnModel.setColumnMargin >> (DefaultTableColumnModel.java:171) >> at javax.swing.JTable.setIntercellSpacing (JTable.java:2950) >> at javax.swing.JTable.initializeLocalVars (JTable.java:1720) >> at javax.swing.JTable.<init> (JTable.java:1664) >> at javax.swing.JTable.<init> (JTable.java:1582) >> at jmemorize.gui.swing.CardTable.<init> (Unknown Source) >> at jmemorize.gui.swing.FindFrame.<init> (Unknown Source) >> at jmemorize.gui.swing.MainFrame.<init> (Unknown Source) >> at jmemorize.core.Main.run (Unknown Source) >> at jmemorize.core.Main.main (Unknown Source) >> at java.lang.reflect.Method.invokeNative (Native Method) >> ...2 more >> >> Since there are some Swing hackers who frequently work on JTable this >> might be a >> low hanging fruit for them. >> >> cya >> Robert >> >> [0] - http://riad.de/jmemorize >> >> > > > >