📄 loginbean.java
字号:
package com.jlib.client;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Font;
import java.io.IOException;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.JPasswordField;
import javax.swing.JCheckBox;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import java.awt.Toolkit;
import javax.swing.JToggleButton;
public class LoginBean extends JFrame {
public static String IP = null;
public static int PORT;
private ButtonGroup buttonGroup = new ButtonGroup();
public static final long serialVersionUID = 1L;
public JPanel jContentPane = null;
private JLabel jLabel = null;
private JPanel jPanel = null;
private JPanel jPanel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
public static JTextField jTextField = null;
private JLabel jLabel1 = null;
private JButton jButton1 = null;
private JPasswordField jPasswordField = null;
private JLabel jLabel4 = null;
private JButton jButton2 = null;
private JButton jButton3 = null;
private JCheckBox jCheckBox = null;
private JCheckBox jCheckBox1 = null;
boolean d = false;
private JToggleButton jToggleButton = null;
private JPanel jPanel2 = null;
private JLabel jLabel5 = null;
public JTextField jTextField1 = null;
private JLabel jLabel6 = null;
public JTextField jTextField2 = null;
public JPanel jPanel3 = null;
public JLabel jLabel7 = null;
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
try {
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBackground(new Color(221, 249, 250));
jPanel.setBorder(BorderFactory.createCompoundBorder(null, null));
jPanel.setPreferredSize(new Dimension(1, 120));
jPanel.add(getJPanel1(), null);
jPanel.add(getJButton2(), null);
jPanel.add(getJButton3(), null);
jPanel.add(getJToggleButton(), null);
jPanel.add(getJPanel3(), null);
} catch (java.lang.Throwable e) {
// TODO: Something
}
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
try {
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(231, 61, 63, 18));
jLabel4.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 12));
jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setForeground(new Color(49, 92, 254));
jLabel4.setText("技术支持");
jLabel4.addMouseListener(new java.awt.event.MouseListener() {
public void mousePressed(java.awt.event.MouseEvent e) {
System.out.println("mousePressed()"); // TODO Auto-generated Event stub mousePressed()
try {
Runtime.getRuntime().exec(
"rundll32 url.dll,FileProtocolHandler "+ "http://www.csdn.net/");
} catch (IOException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
}
public void mouseClicked(java.awt.event.MouseEvent e) {
System.out.println("mouseClicked");
}
public void mouseReleased(java.awt.event.MouseEvent e) {
System.out.println("mouseReleased");
}
public void mouseEntered(java.awt.event.MouseEvent e) {
System.out.println("mouseEntered()");
if(e.getSource()==jLabel4){
jLabel4.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
}
public void mouseExited(java.awt.event.MouseEvent e) {
System.out.println("mouseExited");
d = false;
jLabel4.repaint();
}
});
class Putline{
@SuppressWarnings("unused")
public void paintBorder(Graphics g){
int w = jLabel4.getSize().width;
int h = jLabel4.getSize().height;
if(d){
g.drawLine(0, h-1, w-1, h-1);
}
}
}
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(1, 1, 306, 117));
jLabel1.setIcon(new ImageIcon(getClass().getResource("/com/jlib/client/pg.jpg")));
jLabel1.setText("");
jLabel1.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
jLabel3 = new JLabel();
jLabel3.setLocation(new Point(18, 60));
jLabel3.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 12));
jLabel3.setText("用户密码");
jLabel3.setSize(new Dimension(50, 20));
jLabel2 = new JLabel();
jLabel2.setLocation(new Point(18, 21));
jLabel2.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 12));
jLabel2.setText("用户账号");
jLabel2.setSize(new Dimension(50, 20));
jPanel1 = new JPanel();
jPanel1.setLayout(null);
jPanel1.setBounds(new Rectangle(7, 8, 308, 119));
jPanel1.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
jPanel1.setBorder(BorderFactory.createLineBorder(new Color(19, 101, 115), 1));
jPanel1.add(jLabel2, null);
jPanel1.add(jLabel3, null);
jPanel1.add(getJTextField(), null);
jPanel1.add(getJPasswordField(), null);
jPanel1.add(getJButton1(), null);
jPanel1.add(getJCheckBox1(), null);
jPanel1.add(jLabel4, null);
jPanel1.add(getJCheckBox(), null);
jPanel1.add(jLabel1, jLabel1.getName());
} catch (java.lang.Throwable e) {
// TODO: Something
}
}
return jPanel1;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
try {
jTextField = new JTextField();
jTextField.setText("请输入用户名");
jTextField.setLocation(new Point(86, 22));
jTextField.setSize(new Dimension(135, 18));
} catch (java.lang.Throwable e) {
// TODO: Something
}
}
return jTextField;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
try {
jButton1 = new JButton();
jButton1.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 12));
jButton1.setSize(new Dimension(71, 20));
jButton1.setLocation(new Point(230, 22));
jButton1.setPreferredSize(new Dimension(70, 27));
jButton1.setForeground(new Color(49, 92, 254));
jButton1.setText("默认");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(e.getSource()==jButton1){
jTextField.setText("");
jPasswordField.setText("");
}
}
});
} catch (java.lang.Throwable e) {
// TODO: Something
}
}
return jButton1;
}
/**
* This method initializes jPasswordField
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
try {
jPasswordField = new JPasswordField();
jPasswordField.setText("");
jPasswordField.setSize(new Dimension(135, 18));
jPasswordField.setLocation(new Point(86, 60));
} catch (java.lang.Throwable e) {
// TODO: Something
}
}
return jPasswordField;
}
/**
* This method initializes jButton2
*
* @return javax.swing.JButton
*/
private JButton getJButton2() {
if (jButton2 == null) {
try {
jButton2 = new JButton();
jButton2.setBounds(new Rectangle(150, 137, 75, 20));
jButton2.setFont(new Font("\u5b8b\u4f53", Font.PLAIN, 12));
jButton2.setSelected(false);
jButton2.setForeground(new Color(49, 92, 254));
jButton2.setText("登陆");
jButton2.addActionListener(new java.awt.event.ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if(e.getSource()==jButton2){
if(jCheckBox1.isSelected()){
IP = jTextField1.getText();
PORT = Integer.parseInt(jTextField2.getText());
ClientPort cp = new ClientPort(LoginBean.this);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -