简体   繁体   中英

Position 4 JPanel in a JFrame in this way

How can I position 4 JPanel like the img below

在此处输入图片说明

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 ?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM