package com.jia.lesson;
import javax.swing.*;
import java.awt.*;
public class TestJPanel extends JFrame {
public TestJPanel() {
Container container = getContentPane();
//后面参数的意思是间距
container.setLayout(new GridLayout(2,1,10,10));
JPanel jPanel = new JPanel(new GridLayout(1,3));
jPanel.add(new Button("1"));
jPanel.add(new Button("1"));
jPanel.add(new Button("1"));
container.add(jPanel);
this.setVisible(true);
this.setSize(500,500);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new TestJPanel();
}
}
文本域,JScroll面板
最新推荐文章于 2023-12-27 14:51:50 发布