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

BasicInternalFrameUI.installDefaults() fails - ClassCastException if content pane not JComponent.

XMLWordPrintable

    • b94
    • x86
    • windows_xp

      http://forums.java.net/jive/thread.jspa?messageID=121703#121703

      BasicInternalFrameUI.installDefaults() fails with a ClassCastException during a UI switch if the content pane is not a JComponent. Compile and run the attached, then wait for a second for the ClassCastException during the automatic UI switch:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class InternalFrameDemo2 extends JFrame {
          
          JDesktopPane desktop;
          
          public InternalFrameDemo2() {
              super("InternalFrameDemo");
              setBounds(50, 50, 800, 600);
              desktop = new JDesktopPane();
              createFrame();
              setContentPane(desktop);
          }
          
          protected void createFrame() {
              final JInternalFrame internalFrame = new JInternalFrame("Test bug");
              internalFrame.setSize(500,300);
              internalFrame.setLocation(30,30);
              internalFrame.setVisible(true);
              Container c = new Container();
              c.setLayout(new BorderLayout());
              internalFrame.setContentPane(c);
              desktop.add(internalFrame);
              try {
                  internalFrame.setSelected(true);
              } catch (java.beans.PropertyVetoException e) {}
              ActionListener al = new ActionListener(){
                  public void actionPerformed(ActionEvent e){
                     SwingUtilities.updateComponentTreeUI(internalFrame);
                  }
              };
              Timer t = new Timer(2000, al);
              t.start();
          }
          
          private static void createAndShowGUI() {
              JFrame.setDefaultLookAndFeelDecorated(true);
              InternalFrameDemo2 frame = new InternalFrameDemo2();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
          }
          
          public static void main(String[] args) {
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }
      }

            mbronsonsunw Mike Bronson (Inactive)
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: