码迷,mamicode.com
首页 > 编程语言 > 详细

java用户界面—创建一个面板

时间:2017-06-20 20:13:13      阅读:179      评论:0      收藏:0      [点我收藏+]

标签: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);
} }

java用户界面—创建一个面板

标签:tcl   set   jpanel   java   layout   jpa   vax   seo   null   

原文地址:http://www.cnblogs.com/F001li/p/7055959.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!