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

JComboBox.setPopupVisible method throws ClassCastException exception

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: nkR10003 Date: 01/19/2001


      JComboBox.setPopupVisible method throws ClassCastException exception
      when auxiliary L&F is installed.

      See example below:

      %java -fullversion
      java full version "1.4.0-beta-b46"
      ------------------example--------------------
      import javax.swing.plaf.metal.*;
      import javax.swing.plaf.*;
      import javax.swing.*;
      import java.lang.reflect.*;

      public class test {
          public static void main(String[] args) {
              LookAndFeel lnf = new AuxLookAndFeel();
              try {
                  UIManager.addAuxiliaryLookAndFeel(lnf);
              
                  final JComboBox multiComboBox = new JComboBox();
                 
                  JFrame frame = new JFrame("test");
                  frame.getContentPane().add(multiComboBox);
                  frame.setVisible(true);
                  try {
                      SwingUtilities.invokeAndWait(new Runnable() {
                          public synchronized void run() {
                              multiComboBox.setPopupVisible(true);
                          }
                      });
                  } catch (InterruptedException ie) {
                      ie.printStackTrace();
                      System.out.println("Test Failed. Unexpected exception: " + ie);
                      System.exit(0);
                  } catch (InvocationTargetException ite) {
                      ite.printStackTrace();
                      System.out.println("Test Failed. Unexpected exception: " + ite);
                      System.exit(0);
                  } finally {
                      frame.dispose();
                  }
              
              } finally {
                  UIManager.removeAuxiliaryLookAndFeel(lnf);
                  System.out.println("Test passed: OK");
                  System.exit(0);
              }
          }
      }

      class AuxLookAndFeel extends MetalLookAndFeel {
          public AuxLookAndFeel() {
              super();
          }
      }
      ----------------output:----------------------
      java.lang.reflect.InvocationTargetException
      at java.awt.EventQueue.invokeAndWait(EventQueue.java:706)
      at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1200)
      at test.main(test.java:18)
      Caused by: java.lang.ClassCastException: javax.swing.plaf.multi.MultiPopupMenuUI
      at javax.swing.plaf.basic.BasicPopupMenuUI$PropertyChangeHandler.propertyChange(BasicPopupMenuUI.java:185)
      at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:268)
      at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:236)
      at javax.swing.JComponent.firePropertyChange(JComponent.java:3584)
      at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:684)
      at javax.swing.JPopupMenu.show(JPopupMenu.java:842)
      at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:133)
      at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(BasicComboBoxUI.java:818)
      at javax.swing.plaf.multi.MultiComboBoxUI.setPopupVisible(MultiComboBoxUI.java:61)
      at javax.swing.JComboBox.setPopupVisible(JComboBox.java:661)
      at test$1.run(test.java:20)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:147)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:435)
      at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
      Test Failed. Unexpected exception: java.lang.reflect.InvocationTargetException
      ---------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mdavidsosunw Mark Davidson (Inactive)
              Reporter:
              knasunw Kna Kna (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: