当前位置:文档之家› JAVA语言登陆界面设计

JAVA语言登陆界面设计

登陆界面设计
程序:
import javax.swing.*;
import java.awt.*;
public class登陆界面设计extends JFrame{
public登陆界面设计(){ //构造方法名称要与类名称一致this.setTitle("学生系统登陆界面");
this.setForeground(Color.blue);
this.setBounds(200, 200, 400, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JLabel labname=new JLabel("登陆名:");
JLabel labpassed=new JLabel("登陆密码:");
JTextField tex1=new JTextField("");
JTextField tex2=new JTextField("");
JButton bun1=new JButton("登陆");
JButton bun2=new JButton("退出");
JPanel panel =(JPanel) this.getContentPane();
panel.setLayout(null);
panel.setBackground(Color.green);
panel.add(labname);
labname.setBounds(100, 60, 100, 30);
// labname.setForeground(Color.red);
labname.setFont(new Font(null,Font.ITALIC,20));
panel.add(tex1);
tex1.setBounds(200, 60, 100, 30);
// tex1.setForeground(Color.red);
tex1.setFont(new Font(null,Font.ITALIC,20));
panel.add(labpassed);
labpassed.setBounds(100, 120, 100, 30);
// labpassed.setForeground(Color.red);
labpassed.setFont(new Font(null,Font.ITALIC,20));
panel.add(tex2);
tex2.setBounds(200, 120, 100, 30);
// tex2.setForeground(Color.red);
tex2.setFont(new Font(null,Font.ITALIC,20));
panel.add(bun1);
bun1.setBounds(100, 180, 100, 50);
bun1.setForeground(Color.red);
bun1.setFont(new Font(null,Font.ITALIC,20));
panel.add(bun2);
bun2.setBounds(210, 180, 100, 50);
bun2.setForeground(Color.red);
bun2.setFont(new Font(null,Font.ITALIC,20));
this.setVisible(true);
}
public static void main(String[] args) { new登陆界面设计();
}
}
运行效果图:。

相关主题