Skip to main content

Could you repeat the exception on your Windows XP machine?

4 replies [Last post]
andrein
Offline
Joined: 2005-12-19

Hi everybody

yesterday I filed a bug report concerning Java mustang and Windows XP tool Accessibility Magnifier. Unfortunately, the bug report was not accepted because the problem could not be repeated on a reviewer

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
leouser
Offline
Joined: 2005-12-12

I can recreate it without Windows XP:

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

public class InternalFrameDemo extends JFrame {

JDesktopPane desktop;

public InternalFrameDemo() {
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());
c.add(new JLabel("Invoke Windows utility tool Magnifier
" +
" and Exception should be thrown.", SwingConstants.CENTER));
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);
InternalFrameDemo frame = new InternalFrameDemo();
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();
}
});
}
}
---------------
The problem is that the BasicInternalFrameUI is expecting the content pane to be a JComponent of some sort, Container is higher up and so we get a ClassCastException. Im not sure why the code is casting it to a JComponent given that it appears the operations it performs can be done on a Container as well. In any case, the report should really be:
"Updating UI of JInternalFrame with BasicInternalFrameUI causes ClassCastException if Content pane is not a JComponent"

If you put a new bug report in and it gets accepted, make note of it here and Ill see if I can do a Collab patch for it. :)

Im guessing your windows magnifier somehow triggered a UI update, not sure why but it must have.

leouser

shan_man
Offline
Joined: 2005-05-31

I've accepted this as bug 6437493.

Thanks!
Shannon

leouser
Offline
Joined: 2005-12-12

just sent in the Collab patch. FYI, this bug will definately appear in Metal and should appear in Windows LAF. Motif and GTK appear untouched.

leouser

timbell
Offline
Joined: 2003-06-10

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

Here is the forum thread for the fix leouser just added:

https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?...

Thanks for jumping on this - that's a quick turnaround!

Tim