-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
1.4.1
-
x86
-
windows_xp
Name: jk109818 Date: 10/28/2002
FULL PRODUCT VERSION :
java version "1.4.0_02"
Java(TM) 2 Runtime Environment, Standard Edition {build 1.4.0_02-b02)
Java HotSpot(TM) Client VM (build 1.4.0_02-b02, mixed mode)
AND
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Micorsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When maximizing a JInternalFrame before adding it to a
JDesktopPane, it causes a NullPointerException to be
thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run JIFTest
2. click Frame -> New
3. click Frame -> New (again)
EXPECTED VERSUS ACTUAL BEHAVIOR :
Every other JInternalFrame should appear maximized, but
causes an NPE.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at javax.swing.DefaultDesktopManager.maximizeFrame
(DefaultDesktopManager.java:87)
at javax.swing.plaf.basic.BasicInternalFrameUI.maximizeFrame
(BasicInternalFrameUI.java:629)
at
javax.swing.plaf.basic.BasicInternalFrameUI$InternalFramePropertyChangeListener
.propertyChange(BasicInternalFrameUI.java:437)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
(SwingPropertyChangeSupport.java:264)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange
(SwingPropertyChangeSupport.java:232)
at javax.swing.JComponent.firePropertyChange(JComponent.java:3801)
at javax.swing.JInternalFrame.setMaximum(JInternalFrame.java:964)
at test.JIFTest.createFrame(JIFTest.java:60)
at test.JIFTest$2.actionPerformed(JIFTest.java:44)
at javax.swing.AbstractButton.fireActionPerformed
(AbstractButton.java:1767)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
(AbstractButton.java:1820)
at javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed
(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick
(BasicMenuItemUI.java:1092)
at
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased
(BasicMenuItemUI.java:932)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1525)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1582)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.LightweightDispatcher.retargetMouseEvent
(Container.java:3359)
at java.awt.LightweightDispatcher.processMouseEvent
(Container.java:3074)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3004)
at java.awt.Container.dispatchEventImpl(Container.java:1568)
at java.awt.Window.dispatchEventImpl(Window.java:1581)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:191)
at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents
(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.pumpEvents
(EventDispatchThread.java:130)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
^C
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.beans.*;
public class JIFTest extends javax.swing.JFrame {
JDesktopPane desktop;
int frameCount = 0;
int x = 30;
int y = 10;
public JIFTest() {
super("JInternalFrameTest");
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit
().getScreenSize();
setBounds(inset, inset, screenSize.width - inset*2,
screenSize.height-inset*2);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
desktop = new JDesktopPane();
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
setContentPane(desktop);
setJMenuBar(createMenuBar());
}
protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menuFrame = new JMenu("Frame");
menuFrame.setMnemonic(KeyEvent.VK_F);
JMenuItem menuItemNew = new JMenuItem("New");
menuItemNew.setMnemonic(KeyEvent.VK_N);
menuItemNew.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createFrame();
}
});
menuFrame.add(menuItemNew);
menuBar.add(menuFrame);
return menuBar;
}
protected void createFrame() {
JInternalFrame frame = new JInternalFrame("Frame #" +
++frameCount,true,true,true,true);
frame.setSize(300,300);
frame.setLocation(x*frameCount, y*frameCount);
frame.setVisible(true);
try {
frame.setMaximum(frameCount % 2 == 0);
System.out.println("frame(" + new Integer
(frameCount).toString() + ").isMaximum: " + frame.isMaximum());
} catch(PropertyVetoException e) {
System.out.println("Exception caught");
}
desktop.add(frame);
try {
frame.setSelected(true);
} catch(java.beans.PropertyVetoException e) {}
}
public static void main(String[] args) {
JIFTest f = new JIFTest();
f.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
The workaround is first adding the JIF to the Desktop and
THEN maximizing it, but this is not always possible (for
instance when reading it from an XML file using
XMLDecoder).
(Review ID: 166236)
======================================================================
- relates to
-
JDK-6486046 NullPointerException when calling javax.swing.JInternalFrame.setMaximum(true)
-
- Closed
-