NPLS
NPLS

Reputation: 529

Position 4 JPanel in a JFrame in this way

How can I position 4 JPanel like the img below

enter image description here

public class Main {

    static JFrame frame;

    public static void main(String[]args){
            frame = new JFrame("TPTPRG");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           // frame.setResizable(false);
            //Add content to the window.
            frame.add(new JPanelNumber1(), BorderLayout.?????);
            frame.add(new JPanelNumber2(), BorderLayout.?????);
            frame.add(new JPanelNumber3(), BorderLayout.?????);
            frame.add(new JPanelNumber4(), BorderLayout.?????);


            //frame.setUndecorated(true);

            //frame.setBackground(new Color(0, 255, 0, 0));
            //new FullScreen().setFullScreen(frame); // full screen JFrame, works
            frame.pack();
            frame.setVisible(true);
    }

}

Or is better if I add the 4 JPanel in a JPanel_Main ?

Upvotes: 2

Views: 482

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

frame.add(new JPanelNumber1(), BorderLayout.LINE_START);
frame.add(new JPanelNumber2(), BorderLayout.PAGE_END);
frame.add(new JPanelNumber3(), BorderLayout.LINE_END);
frame.add(new JPanelNumber4(), BorderLayout.CENTER);

Upvotes: 4

Related Questions