Skip to main content

Could you repeat the exception on your Windows XP machine?

4 replies [Last post]
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,

(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>    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>    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>    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(<br />
        at javax.swing.plaf.basic.BasicInternalFrameUI.installUI(<br />
        at javax.swing.plaf.metal.MetalInternalFrameUI.installUI(<br />
        at javax.swing.JComponent.setUI(<br />
        at javax.swing.JInternalFrame.setUI(<br />
        at javax.swing.JInternalFrame.updateUI(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI0(<br />
        at javax.swing.SwingUtilities.updateComponentTreeUI(<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateWindowUI(<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.updateAllUIs(<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener.access$200(<br />
        at javax.swing.plaf.metal.MetalLookAndFeel$AATextListener$<br />
        at java.awt.event.InvocationEvent.dispatch(<br />
        at java.awt.EventQueue.dispatchEvent(<br />
        at java.awt.EventDispatchThread.pumpOneEventForFilters(<br />
        at java.awt.EventDispatchThread.pumpEventsForFilter(<br />
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(<br />
        at java.awt.EventDispatchThread.pumpEvents(<br />
        at java.awt.EventDispatchThread.pumpEvents(<br />
        at<br />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
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() {
setBounds(50, 50, 800, 600);
desktop = new JDesktopPane();

protected void createFrame() {
final JInternalFrame internalFrame = new JInternalFrame("Test bug");
Container c = new Container();
c.setLayout(new BorderLayout());
c.add(new JLabel("Invoke Windows utility tool Magnifier
" +
" and Exception should be thrown.", SwingConstants.CENTER));
try {
} catch (java.beans.PropertyVetoException e) {}
ActionListener al = new ActionListener(){
public void actionPerformed(ActionEvent e){
Timer t = new Timer(2000, al);

private static void createAndShowGUI() {
InternalFrameDemo frame = new InternalFrameDemo();

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
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.


Joined: 2005-05-31

I've accepted this as bug 6437493.


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.


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:

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