JavaIcq登录界面
来源:互联网 发布:龙门县网络问政 编辑:程序博客网 时间:2024/04/30 10:46
package com.korui.icq.view;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import com.korui.icq.swing.IpAddressField;
import com.korui.icq.util.SwingTools;
/**
*
* NAME : com.korui.icq.view.LoginView
* Description : JavaICQ客户端登录窗口
*
* @author zhaoliang
* @date 2009-08-01
* @version 1.0
* @see
*
* REVISIONS:
* Version Date Author Description
* --------------------------------------------------------
* 1.0 2009-08-01 zhaoliang Created
*
* --------------------------------------------------------
*/
public class LoginView {
private JFrame frame;
private JPanel centerPanel, southPanel, checkBoxPanel;
private JTextField serverAddressField;
//private JComboBox icqField;
private JTextField icqField;
private JPasswordField passwordField;
private JLabel logoLabel, serverAddressLabel, icqLabel, passwordLabel;
//private ImageIcon imageIcon;
private JCheckBox checkBox_1, checkBox_2;
private JButton logonButton, cancelButton, registerButton, clearButton;
//用于验证是否超时
private static boolean isOverTime = false;
public LoginView() {
initialize();
addEventHandler();
}
private void initialize() {
frame = new JFrame();
frame.setTitle("JavaICQ用户登录");
frame.setLayout(new BorderLayout());
logoLabel = new JLabel();
Image image = Toolkit.getDefaultToolkit().getImage(LoginView.class.getResource("image/login.png"));
ImageIcon icon = new ImageIcon(image);
logoLabel.setIcon(icon);
logoLabel.setBounds(0, 0, 351, 43);
frame.add(logoLabel, BorderLayout.NORTH);
serverAddressLabel = new JLabel();
serverAddressLabel.setText("服务器地址:");
//serverAddressField = new IpAddressField();
serverAddressField = new JTextField();
icqLabel = new JLabel();
icqLabel.setText("ICQ 号码:");
icqField = new JTextField();
icqField.setEditable(true);
icqField.setSize(10, 10);
clearButton = new JButton();
clearButton.setText("清除");
passwordLabel = new JLabel();
passwordLabel.setText("ICQ 密码:");
passwordField = new JPasswordField();
checkBox_1 = new JCheckBox();
checkBox_1.setText("自动登录");
checkBox_2 = new JCheckBox();
checkBox_2.setText("隐身登录");
centerPanel = new JPanel();
GridBagLayout gridBagLayout = new GridBagLayout();
centerPanel.setLayout(gridBagLayout);
GridBagConstraints n = new GridBagConstraints();
n.gridx = 0;
n.gridy = 0;
n.ipady = 10;
gridBagLayout.setConstraints(serverAddressLabel, n);
centerPanel.add(serverAddressLabel);
GridBagConstraints n1 = new GridBagConstraints();
n1.gridx = 0;
n1.gridy = 1;
n1.ipady = 10;
n1.anchor = GridBagConstraints.EAST;
gridBagLayout.setConstraints(icqLabel, n1);
centerPanel.add(icqLabel);
GridBagConstraints n2 = new GridBagConstraints();
n2.gridx = 0;
n2.gridy = 2;
n2.ipady = 10;
n2.anchor = GridBagConstraints.EAST;
gridBagLayout.setConstraints(passwordLabel, n2);
centerPanel.add(passwordLabel);
GridBagConstraints m = new GridBagConstraints();
m.gridx = 2;
m.gridy = 0;
m.ipadx = 150;
gridBagLayout.setConstraints(serverAddressField, m);
centerPanel.add(serverAddressField);
GridBagConstraints m1 = new GridBagConstraints();
m1.gridx = 2;
m1.gridy = 1;
m1.ipadx = 150;
gridBagLayout.setConstraints(icqField, m1);
centerPanel.add(icqField);
GridBagConstraints m2 = new GridBagConstraints();
m2.gridx = 2;
m2.gridy = 2;
m2.ipadx = 150;
gridBagLayout.setConstraints(passwordField, m2);
centerPanel.add(passwordField);
GridBagConstraints o = new GridBagConstraints();
o.gridx = 3;
o.gridy = 1;
o.insets = new Insets(1, 0, 1, 0);
gridBagLayout.setConstraints(clearButton, o);
centerPanel.add(clearButton);
checkBoxPanel = new JPanel();
checkBoxPanel.add(checkBox_1);
checkBoxPanel.add(checkBox_2);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 1;
c.gridy = 3;
c.gridwidth = 2;
gridBagLayout.setConstraints(checkBoxPanel, c);
centerPanel.add(checkBoxPanel);
frame.add(centerPanel, BorderLayout.CENTER);
southPanel = new JPanel();
logonButton = new JButton();
logonButton.setText("登 录");
cancelButton = new JButton();
cancelButton.setText("取 消");
registerButton = new JButton();
registerButton.setText("注册向导");
southPanel.add(logonButton);
southPanel.add(cancelButton);
southPanel.add(registerButton);
frame.add(southPanel, BorderLayout.SOUTH);
}
public void addEventHandler() {
logonButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
logon();
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
System.exit(0);
}
});
registerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
register();
}
});
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clear();
}
});
passwordField.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_ENTER) {
logon();
}
}
});
}
private void logon() {
frame.dispose();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new ChatFrame().showGui();
}
});
}
private void register() {
frame.dispose();
new RegisterWizardView();
}
private void clear() {
}
public void showGui() {
frame.setSize(357, 250);
SwingTools.setSizeAndCenter(frame, frame.getWidth(), frame.getHeight());
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new LoginView().showGui();
}
});
}
}
- JavaIcq登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- 登录界面
- Spring技术内幕——深入解析Spring架构与设计原理(一)IOC实现原理
- 手动解决dll文件无法删除的问题
- 利用PHP应用图像处理生成验证码
- Domino程序常见错误中文解释
- 163相册批量下载程序
- JavaIcq登录界面
- 关于设计成本核算的几个问题[转帖]
- looknfeel中的Button控件的学习
- SAP R/3
- FromHandle(HANDLE h)
- MX记录和spf记录
- WIN32用户界面设计基础之Dialog 篇
- Java基础巩固:static、this、super、final用法
- DWR 最基础应用