I have a main JFrame (1), after that I want to put a JDialog (2) below (same left border position):
dialog2.setLocation(frame.getX(), frame.getY() + frame.getHeight());
and put another JDialog (3) next to the right (same top border position):
dialog3.setLocation(frame.getX() + frame.getWidth(), frame.getY());
But the display has some strange padding among these frame & dialogs:
Test code:
public class Test {
public static void main(String[] args) throws Exception {
JFrame mainFrame = new JFrame();
mainFrame.setSize(400, 400);
mainFrame.setVisible(true);
JFrame dialog = new JFrame(); // JDialog dialog = new JDialog();
dialog.setSize(400, 400);
dialog.setLocation(mainFrame.getX() + mainFrame.getWidth(), mainFrame.getY());
dialog.setVisible(true);
JFrame dialog1 = new JFrame(); // JDialog dialog1 = new JDialog();
dialog1.setSize(400, 400);
dialog1.setVisible(true);
dialog1.setLocation(mainFrame.getX(), mainFrame.getY() + mainFrame.getHeight());
}
}
Can anybody explain why and suggestion solution that makes those get closer without any padding?