Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6785663

ClassCastException thrown when running Java2Demo with Nimbus Look And Feel



    • generic, x86
    • generic, windows_xp


      I am Launching Java2Demo on WinXP with 6u12-b03 PIT build and I am passing the nimbus look and feel flag as an argument. Java2Demo opens a progress bar. While the loading is in progress, I get the following exception on the console and Demo stops loading there -

      Exception in thread "main" java.lang.ClassCastException: com.sun.java.swing.plaf.nimbus.DerivedColor$UIResource cannot be cast to java.awt.Font
      at com.sun.java.swing.plaf.nimbus.NimbusStyle.getFontForState(NimbusStyle.java:685)
      at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:916)
      at com.sun.java.swing.plaf.nimbus.NimbusStyle.installDefaults(NimbusStyle.java:214)
      at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:899)
      at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:276)
      at javax.swing.plaf.synth.SynthPanelUI.updateStyle(SynthPanelUI.java:70)
      at javax.swing.plaf.synth.SynthPanelUI.installDefaults(SynthPanelUI.java:57)
      at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:39)
      at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:37)
      at javax.swing.JComponent.setUI(JComponent.java:673)
      at javax.swing.JPanel.setUI(JPanel.java:136)
      at javax.swing.JPanel.updateUI(JPanel.java:109)
      at javax.swing.JPanel.<init>(JPanel.java:69)
      at javax.swing.JPanel.<init>(JPanel.java:78)
      at java2d.DemoGroup.<init>(DemoGroup.java:79)
      at java2d.Java2Demo.<init>(Java2Demo.java:140)
      at java2d.Java2Demo.main(Java2Demo.java:483)

      The above exception is specific to Nimbus LAF and not seen on Metal. Also this exception is inconsistant and not thrown always. However, I am able to reproduce it more consistantly when I disable the hardware acceleration in the Display Settings. Right click on the desktop and go to properties -> Advanced -> Troubleshoot. Move the slider towards the left.

      This doesn't look like a regression because it is seen with 6u11 as well. I tried this on WinXP SP3 - Nvidia GeForce 7600 - No HW Accel - 16bit color depth.

      To reproduce the bug, just disable HW acceleration and choose 16bit color depth. Launch Java2Demo as follows -
      java -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel -jar java2Demo.jar

      Try it a few times and you will get the above exception.
      This is also reproducible with jdk6u10-b33. Also reproducible on SolSparc10. I have changed the release to 6u10 in SR.


        Issue Links



              peterz Peter Zhelezniakov
              pmohansunw Praveen Mohan (Inactive)
              0 Vote for this issue
              0 Start watching this issue