标签:tcl set jpanel java layout jpa vax seo null
先从基础学起
创建一个面板
代码如下:
package Day08; import java.awt.FlowLayout; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Homework1 extends JFrame {
public Homework1() {
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
p1.add(new JButton("JButton1-1"));
p1.add(new JButton("JButton1-2"));
p1.add(new JButton("JButton1-3"));
JPanel p2 = new JPanel();
p2 .setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
p2.add(new JButton("JButton2-1"));
p2.add(new JButton("JButton2-2"));
p2.add(new JButton("JButton2-3"));
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
add(p1);
add(p2);
}
public static void main(String[] args) {
Homework1 frame = new Homework1();
frame.setSize(500, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
标签:tcl set jpanel java layout jpa vax seo null
原文地址:http://www.cnblogs.com/F001li/p/7055959.html