swing简单模仿QQ登陆界面
效果图
<ignore_js_op>
代码如下
- package Game;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- class Qq{
- public void showLoginFrame(){
- final JFrame loginFrame=new JFrame();
- //设置大小,位置,标题
- loginFrame.setSize(300,200);
- loginFrame.setTitle("QQ2014");
- loginFrame.setLocationRelativeTo(null);
- //创建流式分布对象
- FlowLayout layout=new FlowLayout();
- loginFrame.setLayout(layout);
- //创建账户名,密码和输入框
- JLabel user=new JLabel("账号:");
- JLabel password=new JLabel("密码:");
- final JTextField named=new JTextField(20);
- final JPasswordField password2=new JPasswordField(20);
- //创建登陆,重置按钮
- JButton reset=new JButton("重置");
- JButton login=new JButton("登陆");
- //设置窗体可见
- loginFrame.setVisible(true);
- //创建事件监听对象
- ActionListener listener1=new ActionListener(){
- public void actionPerformed(ActionEvent e){
- String name=named.getText();
- String password=password2.getText();
- if("zhaoxin".equals(name)&&"123".equals(password))
- {
- showIndexFrame();
- loginFrame.setDefaultCloseOperation(3);
- loginFrame.setVisible(false);
- }
- else{
- System.out.println("密码错误,重新输入!");
- }
- }
- .......
posted on 2014-11-18 09:42 wangniuzen 阅读(1748) 评论(0) 编辑 收藏 举报