如何定位4个JPanel,如下面的img
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);
}
}
或者如果我在JPanel_Main中添加4个JPanel会更好吗?
答案 0 :(得分:4)
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);