11csdn-java周末作业(登陆界面)
2012-05-06 21:32
671 查看
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Login implements ActionListener{
Frame frame;
TextField txtName;
TextField Password;
public Login(){
frame=new Frame();
frame.setTitle("登陆界面");
Panel p1,p2,p3,p4;
Label label1=new Label("请输入你的用户信息:");
Label label2=new Label("用户名:");
txtName=new TextField(10);
Label label3=new Label("密 码:");
Password=new TextField(10);
Button button1=new Button("确定");
Button button2=new Button("重置");
p1=new Panel();
p2=new Panel();
p3=new Panel();
p4=new Panel();
frame.add(label1,"North");
p1.setLayout(new BorderLayout());
p2.setLayout(new GridLayout(2,1));
p2.add(label2);
p2.add(label3);
p3.setLayout(new GridLayout(2,1));
p3.add(txtName);
p3.add(Password);
p1.add(p2, "West");
p1.add(p3, "Center");
txtName.addActionListener(this);
Password.addActionListener(this);
p4.add(button1);
p4.add(button2);
button1.addActionListener(this);
button2.addActionListener(this);
frame.add(p1,"Center");
frame.add(p4,"South");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setSize(220, 130);
frame.setLocation(300, 200);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String str=e.getActionCommand();
if(str.equals("确定")){
submit();
}else{
clear();
}
}
private void clear() {
txtName.setText("");
Password.setText("");
}
private void submit() {
JOptionPane.showMessageDialog(frame,"登陆成功");
}
public static void main(String[] args) {
new Login();
}
}
import java.awt.event.*;
import javax.swing.*;
public class Login implements ActionListener{
Frame frame;
TextField txtName;
TextField Password;
public Login(){
frame=new Frame();
frame.setTitle("登陆界面");
Panel p1,p2,p3,p4;
Label label1=new Label("请输入你的用户信息:");
Label label2=new Label("用户名:");
txtName=new TextField(10);
Label label3=new Label("密 码:");
Password=new TextField(10);
Button button1=new Button("确定");
Button button2=new Button("重置");
p1=new Panel();
p2=new Panel();
p3=new Panel();
p4=new Panel();
frame.add(label1,"North");
p1.setLayout(new BorderLayout());
p2.setLayout(new GridLayout(2,1));
p2.add(label2);
p2.add(label3);
p3.setLayout(new GridLayout(2,1));
p3.add(txtName);
p3.add(Password);
p1.add(p2, "West");
p1.add(p3, "Center");
txtName.addActionListener(this);
Password.addActionListener(this);
p4.add(button1);
p4.add(button2);
button1.addActionListener(this);
button2.addActionListener(this);
frame.add(p1,"Center");
frame.add(p4,"South");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setSize(220, 130);
frame.setLocation(300, 200);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String str=e.getActionCommand();
if(str.equals("确定")){
submit();
}else{
clear();
}
}
private void clear() {
txtName.setText("");
Password.setText("");
}
private void submit() {
JOptionPane.showMessageDialog(frame,"登陆成功");
}
public static void main(String[] args) {
new Login();
}
}
相关文章推荐
- Java用户登陆界面
- 一、使用JAVA_SWT编写登陆界面(不含数据库,登陆按钮未处理)
- java--登陆界面
- JavaSwing图形界面编程之登陆校验码(一)
- //设计登陆窗口界面,当输入账号密码正确时,界面如图一所示,当输入账号密码有误时,界面如图二所示。 import java.awt.*; import java.awt.event.*; import
- 设计登陆窗口界面,当输入账号密码正确时,界面如图一所示,当输入账号密码有误时,界面如图二所示。 import java.awt.*; import java.awt.event.*; import
- java学习笔记之使用MyEclipse写一个简单的登陆界面(二)
- Java用户登陆界面
- 设计登陆窗口界面,当输入账号密码正确时,界面如图一所示,当输入账号密码有误时,界面如图二所示。 import java.awt.*; import java.awt.event.*; import
- 刚学完Java,老师居然没讲界面~~,于是自己上网自学了下,利用周末写下了这个贪吃蛇和他家分享
- 使用java awt 制作登陆,注册界面(结合数据库MY SQL )使用mac系统的eclipse
- 设计登陆窗口界面,当输入账号密码正确时,界面如图一所示,当输入账号密码有误时,界面如图二所示。 import java.awt.*; import java.awt.event.*; import
- java实现的登陆界面
- java Swing QQ登陆界面
- 课后作业之登陆界面
- 登陆界面的java代码
- JAVA之简单界面设计(布局,更改背景图片,按钮监听 + 数据库登陆注册相关..)
- JAVA swing之用户登陆界面
- awt实现登陆界面+数据库——学java,零基础不怕,不只要理论,更要实践+项目<a href=http://www.bjweixin.com>太原维信科技提供 </a>
- JAVA 多进程应用 多个定时器作业的SWING界面及实现 -- s00n