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’s machine that’s why I’m asking Java community if somebody else could repeat the exception on his machine. How? It’s very simple. Just execute the enclosed test case (1) with one of the latest mustang’s build (I have tested b83, b85, b86 and b87 and the exception is always thrown) and invoke Windows Magnifier. My machine is internationalized version of Window XP, Home edition, SP2 [version 5.1.2600]. If the exception (2) is thrown on your machine, please report your observation here or in the Sun’s bug database. I’d just like to add the exception could not be repeated on Java SE 1.5 so I suspect that it’s a regression.

Kind regards and many thanks,
Andrei

(1) Test case:

<br />
import java.awt.Container;<br />
import java.awt.BorderLayout;<br />
import javax.swing.JInternalFrame;<br />
import javax.swing.JDesktopPane;<br />
import javax.swing.JLabel;<br />
import javax.swing.JFrame;<br />
import javax.swing.SwingConstants;</p>
<p>public class InternalFrameDemo extends JFrame {</p>
<p>    JDesktopPane desktop;</p>
<p>    public InternalFrameDemo() {<br />
        super("InternalFrameDemo");<br />
        setBounds(50, 50, 800, 600);<br />
        desktop = new JDesktopPane();<br />
        createFrame();<br />
        setContentPane(desktop);<br />
    }</p>
<p>    protected void createFrame() {<br />
        JInternalFrame internalFrame = new JInternalFrame("Test bug");<br />
        internalFrame.setSize(500,300);<br />
        internalFrame.setLocation(30,30);<br />
        internalFrame.setVisible(true);<br />
        Container c = new Container();<br />
        c.setLayout(new BorderLayout());<br />
        c.add(new JLabel("Invoke Windows utility tool Magnifier" +<br />
            " and Exception should be thrown.", SwingConstants.CENTER));<br />
        internalFrame.setContentPane(c);<br />
        desktop.add(internalFrame);<br />
        try {<br />
            internalFrame.setSelected(true);<br />
        } catch (java.beans.PropertyVetoException e) {}<br />
    }</p>
<p>    private static void createAndShowGUI() {<br />
        JFrame.setDefaultLookAndFeelDecorated(true);<br />
        InternalFrameDemo frame = new InternalFrameDemo();<br />
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />
        frame.setVisible(true);<br />
    }</p>
<p>    public static void main(String[] args) {<br />
        javax.swing.SwingUtilities.invokeLater(new Runnable() {<br />
            public void run() {<br />
                createAndShowGUI();<br />
            }<br />
        });<br />
    }<br />
}<br />

(2) Exception:

<br />
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.awt.Container cannot be cast to javax.swing.JComponent<br />
        at javax.swing.plaf.basic.BasicInternalFrameUI.installDefaults(BasicInternalFrameUI.java:124)<br />
        at javax.swing.plaf.basic.BasicInternalFrameUI.installUI(BasicInternalFrameUI.java:92)<br />
        at javax.swing.plaf.metal.MetalInternalFrameUI.installUI(MetalInternalFrameUI.java:52)<br />
        at javax.swing.JComponent.setUI(JComponent.java:648)<br />
        at javax.swing.JInternalFrame.setUI(JInternalFrame.java:370)<br />
        at javax.swing.JInternalFrame.updateUI(JInternalFrame.java:386)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1206)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1221)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1221)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1221)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1221)<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI(SwingUtilities.java:1197)<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateWindowUI(MetalLookAndFeel.java:1818)<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateAllUIs(MetalLookAndFeel.java:1831)<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.access$200(MetalLookAndFeel.java:1784)<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener$1.run(MetalLookAndFeel.java:1859)<br />
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)<br />
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:598)<br />
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)<br />
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)<br />
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)<br />
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)<br />
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)<br />
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)<br />

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