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

ClassCastException from SynthComboBoxUI in JDK 1.6.0_10 Beta



      When using NetBeans profiler 6.1 running on JDK 1.6.0_10 Beta on GTK LaF (default for Linux & OpenSolaris), profiling results cannot be displayed and HeapWalker tool doesn't work because of ClassCastException from SynthComboBoxUI. The same happens in VisualVM tool because it shares the NB profiler code.

      Issue for tracking this problem on NetBeans side together with more details is at http://www.netbeans.org/issues/show_bug.cgi?id=135812, all bugreports from users are tracked at http://statistics.netbeans.org/analytics/detail.do?id=40178.

      The problem is caused by the fact that border of a JComboBox is assigned to a custom JComponent and recent changes in SynthComboBoxUI which assumes that the border is always painted for JComboBox. Sample code is as follows:

       JTextField textField = new JTextField();
       JComboBox comboBox = new JComboBox();
       textField.setBorder(comboBox.getBorder()); // Here's the problem

      Running sample code on GTK using JDK 1.6.0_10 Beta causes the following exception to be thrown:

       Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JTextField cannot be cast to javax.swing.JComboBox
              at javax.swing.plaf.synth.SynthComboBoxUI.getComponentState(SynthComboBoxUI.java:196)
              at javax.swing.plaf.synth.SynthComboBoxUI.getContext(SynthComboBoxUI.java:183)
              at javax.swing.plaf.synth.SynthBorder.paintBorder(SynthBorder.java:39)
              at javax.swing.JComponent.paintBorder(JComponent.java:922)
              at javax.swing.JComponent.paint(JComponent.java:1028)

      Steps to reproduce:
       1/ Use Linux or OpenSolaris, JDK 1.6.0_10 Beta
       2/ Download VisualVM tool (https://visualvm.dev.java.net), unzip and start it, verify that it's running with GTK LaF
       3/ Right-click VisualVM application node in the Applications tree, invoke Heap Dump action
       4/ Heap dump opens in HeapWalker tool, switch to Classes view, exception is thrown


          Issue Links



              • Assignee:
                stayer Kirill Kirichenko (Inactive)
                thurka Tomáš Hůrka
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: