1

My Java Swing application looks like this if no special look and feel applies:

https://i.stack.imgur.com/cbfXK.jpg

But after I installed the Sea Glass Look and Feel, the program is running but it shows different errors at different times.

I get this exception:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JScrollPane cannot be cast to javax.swing.AbstractButton
at javax.swing.plaf.synth.SynthButtonUI.paint(SynthButtonUI.java:284)
at javax.swing.plaf.synth.SynthButtonUI.update(SynthButtonUI.java:255)
at javax.swing.JComponent.paintComponent(JComponent.java:777)
at javax.swing.JComponent.paint(JComponent.java:1053)
at javax.swing.JComponent.paintChildren(JComponent.java:886)
at javax.swing.JComponent.paint(JComponent.java:1062)
at javax.swing.JComponent.paintChildren(JComponent.java:886)
at javax.swing.JComponent.paint(JComponent.java:1062)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
at javax.swing.JComponent.paintChildren(JComponent.java:886)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5230)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1572)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1495)
at javax.swing.RepaintManager.paint(RepaintManager.java:1265)
at javax.swing.JComponent.paint(JComponent.java:1039)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)
at java.awt.Container.paint(Container.java:1973)
at java.awt.Window.paint(Window.java:3901)
at javax.swing.RepaintManager$4.run(RepaintManager.java:835)
at javax.swing.RepaintManager$4.run(RepaintManager.java:807)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)
at javax.swing.RepaintManager.access$1300(RepaintManager.java:64)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1720)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

This only happens when I apply the Sea Glass Look and Feel.

dic19
  • 17,821
  • 6
  • 40
  • 69
BuxHzk
  • 11
  • 1
  • 1
    Consider providing a [runnable example](https://stackoverflow.com/help/mcve) which demonstrates your problem. This is not a code dump, but an example of what you are doing which highlights the problem you are having. This will result in less confusion and better responses – MadProgrammer May 20 '15 at 06:43
  • @BuxHzk do you use some third party GUI libs? This is the frequent problem, because the third party GUI libs working correct mostly only with the standard L&F – Sergiy Medvynskyy May 20 '15 at 07:59
  • It seems fair that a JScrollPane cannot be casted to a JButton. It would be useful to know which button / which scrollpane is causing the problem. Try commenting some parts of your GUI until this works again. Also: Make sure that all your Swing components are all created on the Event thread, not on the main thread (This can cause many weird bugs related to L&F). – Eric Leibenguth May 20 '15 at 16:17
  • `JScrollPane` cannot be cast to `AbstractButton` regardless of the LAF. The stack trace is near-useless without **actual code** that will show where this happens. The debugger is your best friend in this case. – user1803551 May 20 '15 at 17:40

0 Answers0