java setLocationRelativeTo command help
Ok so i have a GUI JFrame in java that displays a button. When you click the button another JFrame is created with different information etc...
The initial JFrame with the button uses a setLocationRelativeTo(null); to center itself in the middle of the srceen. The second frame I would like to be position at the same location as the first but itstead of being exactly on top of it I would like it to be lets say 20 pixels below it.
开发者_如何学PythonHow would I do this?
You can get the location after using setLocationRelativeTo(null), then you just need to set the location in the second frame:
JFrame f1 = ...;
JFrame f2 = ...;
f1.setLocationRelativeTo(null);
f2.setLocation(new Point(f1.getX(), f2.getY() + 20));
精彩评论