关于JPanel的使用

来源:互联网 发布:淘宝客服一月工资多少 编辑:程序博客网 时间:2024/04/29 07:15
package com;import java.awt.Color;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.border.Border;public class Text extends JFrame {public Text() {this.setLayout(null);JPanel jp = new JPanel();jp.setBounds(300, 50, 150, 150);this.add(jp);//创建红色线性边框Border boder = BorderFactory.createLineBorder(Color.red);//创建带标题边框Border b = BorderFactory.createTitledBorder(boder, "查询员工");//设置小容器的边框jp.setBorder(b);//在小容器里面添加按钮JButton j= new JButton("确定");j.setBounds(20, 20, 80, 20);jp.add(j);this.setSize(500, 400);this.setVisible(true);this.setDefaultCloseOperation(3);this.setLocationRelativeTo(null);this.setResizable(false);}public static void main(String[] args) {Text t = new Text();}}

原创粉丝点击