This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have the following code: public class TinhBan extends javax.swing.JPanel { ... public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; ... } } Which compiled fine but when I ran it I get: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.DebugGraphics at huyenkhong.TinhBan.paintComponent(TinhBan.java:817) at javax.swing.JComponent.paint(JComponent.java:1005) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paint(JComponent.java:1014) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paint(JComponent.java:1014) at javax.swing.JLayeredPane.paint(JLayeredPane.java:559) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4970) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916) at javax.swing.JComponent.paint(JComponent.java:995) at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21) at sun.awt.SunGraphicsCallback.runOneComponent (SunGraphicsCallback.java:60) at sun.awt.SunGraphicsCallback.runComponents (SunGraphicsCallback.java:97) at java.awt.Container.paint(Container.java:1709) at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248) at sun.awt.RepaintArea.paint(RepaintArea.java:224) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254) at java.awt.Component.dispatchEventImpl(Component.java:4031) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Window.dispatchEventImpl(Window.java:1774) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.DebugGraphics at huyenkhong.TinhBan.paintComponent(TinhBan.java:817) at javax.swing.JComponent.paint(JComponent.java:1005) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paint(JComponent.java:1014) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paint(JComponent.java:1014) at javax.swing.JLayeredPane.paint(JLayeredPane.java:559) at javax.swing.JComponent.paintChildren(JComponent.java:842) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4970) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916) at javax.swing.JComponent.paint(JComponent.java:995) at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21) at sun.awt.SunGraphicsCallback.runOneComponent (SunGraphicsCallback.java:60) at sun.awt.SunGraphicsCallback.runComponents (SunGraphicsCallback.java:97) at java.awt.Container.paint(Container.java:1709) at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248) at sun.awt.RepaintArea.paint(RepaintArea.java:224) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254) at java.awt.Component.dispatchEventImpl(Component.java:4031) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Window.dispatchEventImpl(Window.java:1774) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.DebugGraphics at huyenkhong.TinhBan.paintComponent(TinhBan.java:817) at javax.swing.JComponent.paint(JComponent.java:1005) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916) at javax.swing.JComponent._paintImmediately(JComponent.java:4859) at javax.swing.JComponent.paintImmediately(JComponent.java:4666) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run (SystemEventQueueUtilities.java:114) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
When it happened? Is it reproducible in NetBeans IDE only or is it reproducible even outside of the IDE. The paintComponent method is used for printing and the Graphics implementation class could differ for various JRE/JDK. Therefore you cannot just class-cast "g" instance to Graphics2D. Very likely this is not an issue related to Graph module in NetNeans, therefore I am closing this issue as invalid. If you have more information, reopen the issue.
This is graphics casting problem. I just simply casting Graphics to Graphics2D so I can print some rotated text using rotate and transform. The graphic is JPanel's graphic. I am not sure what subcomponent this belong to. If it is not in this subcomponent please advise in what component should it be
I should rephase "print some rotated text" to "draw some rotated text" because the text is being drawn on screen. And yes, it is reproducible. Infact, I cannot run it due to the exception.
I have google for your problem. I have found that you are using a debug option on your (or its parent) component and there is a Swing problem that DebugGraphics is extending Graphics, not Graphics2D. See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4262543 I am closing this bug as invalid since it is not NetBeans Graph module related issue.
closed