发布网友 发布时间:2024-10-24 10:43
共2个回答
热心网友 时间:2024-11-04 14:05
你要是想改大小,就把宽和高改一下就行了
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class SplitPanel extends JFrame{
private static int Width = 400;
private static int Height = 400;
private JPanel upPanel, centerPanel, downPanel, ldPanel, rdPanel;
SplitPanel() {
init();
Container c = getContentPane();
c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
c.add(upPanel);
c.add(centerPanel);
c.add(downPanel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200, 200, Width, Height);
setVisible(true);
}
void init() {
upPanel = new JPanel();
upPanel.setBorder(new TitledBorder("上"));
centerPanel = new JPanel();
centerPanel.setBorder(new TitledBorder("中"));
downPanel = new JPanel();
ldPanel = new JPanel();
ldPanel.setBorder(new TitledBorder("左下"));
rdPanel = new JPanel();
rdPanel.setBorder(new TitledBorder("右下"));
downPanel.setLayout(new GridLayout(1, 2));
downPanel.add(ldPanel);
downPanel.add(rdPanel);
}
public static void main(String[] args) {
new SplitPanel();
}
}
热心网友 时间:2024-11-04 14:06
BorderLayout第一次将其分为上中下,然后再下里面再嵌套一个BorderLayout将其分为左右就行了