Window « Layout « Java Swing Q&A





1. Alignment of components in a gui window    stackoverflow.com

I have got a window that looks like window1 and I would like it to look like window2: enter image description here This is my code:

    String ...

2. GUI shows elements only after dragging window    stackoverflow.com

        frame_ref = new Frame("Login");
        mainPanel_ref = new Panel();
        buttonPanel_ref ...

3. window position    coderanch.com

JFrame frame = (JFrame) new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Get the screen size GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Rectangle bounds = gc.getBounds(); // Create and pack the Elements //.... code to create the panels etc frame.pack(); // Set the Location and Activate Dimension size = frame.getPreferredSize(); frame.setLocation((int) ((bounds.width / 2) - (size.getWidth() / 2)), (int) ((bounds.height / 2) - (size.getHeight() / 2))); frame.setVisible(true); ...