FULL PRODUCT VERSION :
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
dual screen
A DESCRIPTION OF THE PROBLEM :
I have two monitors connected to two different graphic cards.
For some reason i need to change the default behaviour of window. The second monitor has to be treated as the primary one.
(property page of the display and then check the box on the second monitor: Use this as primary monitor)
Next, i want to set the maximumBounds of a Frame I'm going to create.
I calulated the correct values, but somehow the presentation of the Frame is wrong. The width and height is more then I set as maximumBounds.
First Screen: 1600x1200 (positioned at -1600,0)
Second Screen: 1024*768 (positioned at 0,0)
setMaximumBound(new Rectangle(0,0,1600,1200))
Size of Frame is 2176*1598
Something must be caluclated wrong in the LookAndFeel
1600-1024 = 576
1600+576 = 2176
-->If i deactive the LookAndFeel everything works fine
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Frame should be 1600*1200
ACTUAL -
Frame is 2176*1598
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JFrame;
public class TestFrame extends JFrame{
public TestFrame(GraphicsConfiguration gc) {
super(gc);
}
@Override
public synchronized void setExtendedState(int state) {
if((state & MAXIMIZED_BOTH) !=0){
Insets insets = getToolkit().getScreenInsets(getGraphicsConfiguration());
Rectangle bounds = getGraphicsConfiguration().getBounds();
System.out.println("--------------");
System.out.println(getGraphicsConfiguration());
System.out.println(bounds);
bounds.x = insets.left;
bounds.y = insets.top;
bounds.width -= Math.abs(insets.left - insets.right);
bounds.height -= Math.abs(insets.top - insets.bottom);
System.out.println(bounds);
setMaximizedBounds(bounds);
}
super.setExtendedState(state);
}
public static void main(String args[]){
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd[] = ge.getScreenDevices();
TestFrame.setDefaultLookAndFeelDecorated(true);
for (int i = 0; i < gd.length; i++) {
TestFrame frame = new TestFrame(gd[i].getDefaultConfiguration());
Rectangle bounds = frame.getGraphicsConfiguration().getBounds();
frame.setBounds(bounds.x+bounds.width/4, bounds.y+bounds.height/4, bounds.width/2, bounds.height / 2);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
}
---------- END SOURCE ----------