package gui;
import javax.swing.*;
import java.awt.*;
public class JFrameDemo4 extends JFrame {
JPanel p1;
JLabel l1;
JLabel l2;
JLabel l3;
JTextField tf1;
JTextField tf2;
JTextField tf3;
JButton btn1,btn2;
public JFrameDemo4(String title) throws HeadlessException {
super(title);
p1=new JPanel();
p1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
p1.setBorder(BorderFactory.createTitledBorder("登录"));
l1=new JLabel("用户名:");
l2=new JLabel("密 码");
l3=new JLabel("确认密码");
btn1=new JButton("注册");
btn2=new JButton("取消");
tf1=new JTextField(15);
tf2=new JTextField(15);
tf3=new JTextField(15);
this.setContentPane(p1);
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p1.add(l3);
p1.add(tf3);
p1.add(btn1);
p1.add(btn2);
}
public static void main(String[]args){
JFrameDemo4 jf=new JFrameDemo4("面板容器示例");
jf.setBounds(1000,600,250,200);
jf.setResizable(false);
jf.setVisible(true);
}
}
这是一个简单的小面板,对于初学者来说是一个很有价值和意义的练习,🌭🌭🌭🌭🌭