-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: ooR10001 Date: 03/28/2001
javax.swing.JWindow(GraphicsConfiguration conf) constructor incorrectly throws
IllegalArgumentException when passed GraphicsConfiguration is from ScreenDevice
and GraphicsEnvironment.isHeadless() returns false. This behavior contradicts
with current javadoc which says:
-----------------------
public JWindow(GraphicsConfiguration gc)
Creates a window with the specified GraphicsConfiguration of a screen
device. This window will not be focusable.
Parameters:
gc - the GraphicsConfiguration that is used to construct the new
window with; if gc is null, the system default GraphicsConfiguration
is assumed
Throws:
IllegalArgumentException - if gc is not from a screen device. This
exception is always thrown when GraphicsEnvironment.isHeadless()
returns true
-----------------------
This is a test sample which shows the bug:
--------------
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
import javax.swing.JWindow;
public class t {
public static void main(String[] args) {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
GraphicsConfiguration[] cs = gs[0].getConfigurations();
try {
JWindow w = new JWindow(cs[0]);
} catch (IllegalArgumentException iae) {
if (GraphicsEnvironment.isHeadless()) {
System.out.println("Correctly thrown IAE in headless mode");
} else {
System.out.println("Unexpected IAE thrown");
}
}
}
}
--------------
Output:
--------------
Unexpected IAE thrown
--------------
It needs to be fixed.
Proposal fix is to not use call 'this((Frame)null, gc);' in this constructor.
It causes the check that owned window should not be null.
More correctly is to use 'super(gc); windowInit();' calls instead. This calling
sequence is not requred not-null owned window.
======================================================================
- duplicates
-
JDK-4400437 JWindow(GraphicsConfiguration) always throws IllegalArgumentException
- Resolved