📄 frame1.java~44~
字号:
package mis;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import javax.swing.border.*;import org.ietf.jgss.GSSName;import java.io.*;/** * <p>Title: Mis</p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2008</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; XYLayout xYLayout1 = new XYLayout(); TitledBorder titledBorder1; TitledBorder titledBorder2; JPanel jPanel1 = new JPanel(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); XYLayout xYLayout2 = new XYLayout(); JTextField jTextField1 = new JTextField(); JLabel jLabel3 = new JLabel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JPasswordField jPasswordField1 = new JPasswordField(); protected String user="",password=""; //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); titledBorder1 = new TitledBorder(""); titledBorder2 = new TitledBorder(""); contentPane.setBackground(SystemColor.control); contentPane.setBorder(BorderFactory.createLineBorder(Color.black)); contentPane.setMinimumSize(new Dimension(500, 500)); contentPane.setToolTipText(""); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("登陆窗口"); jLabel1.setBackground(SystemColor.text); jLabel1.setFont(new java.awt.Font("Dialog", 1, 20)); jLabel1.setBorder(titledBorder2); jLabel1.setText("身份验证"); jPanel1.setBorder(BorderFactory.createEtchedBorder()); jPanel1.setLayout(xYLayout2); jLabel2.setFont(new java.awt.Font("Dialog", 0, 15)); jLabel2.setText("用户名"); jTextField1.setText(""); jTextField1.addActionListener(new Frame1_jTextField1_actionAdapter(this)); jLabel3.setFont(new java.awt.Font("Dialog", 0, 15)); jLabel3.setText("密码"); jButton1.setFont(new java.awt.Font("Dialog", 1, 15)); jButton1.setText("确定"); jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this)); jButton2.setFont(new java.awt.Font("Dialog", 1, 15)); jButton2.setActionCommand("取消"); jButton2.setText("取消"); jButton2.addActionListener(new Frame1_jButton2_actionAdapter(this)); jPasswordField1.addActionListener(new Frame1_jPasswordField1_actionAdapter(this)); contentPane.add(jLabel1, new XYConstraints(1, 2, 397, 38)); contentPane.add(jPanel1, new XYConstraints(58, 63, 258, 134)); jPanel1.add(jLabel2, new XYConstraints(16, 15, 47, 23)); jPanel1.add(jTextField1, new XYConstraints(82, 11, 160, 26)); jPanel1.add(jLabel3, new XYConstraints(15, 76, 47, 25)); jPanel1.add(jPasswordField1, new XYConstraints(80, 74, 159, 28)); contentPane.add(jButton1, new XYConstraints(56, 235, 110, 32)); contentPane.add(jButton2, new XYConstraints(210, 234, 104, 30)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jButton2_actionPerformed(ActionEvent e) { System.exit(0); } void jTextField1_actionPerformed(ActionEvent e) { } void jPasswordField1_actionPerformed(ActionEvent e) { } void jButton1_actionPerformed(ActionEvent e) { user=jTextField1.getText(); password=jPasswordField1.getText(); if(!user.equalsIgnoreCase("lianghao")){ JOptionPane.showMessageDialog(this,"用户名不存在"); } else if(password.compareTo("123456")!=0){ JOptionPane.showMessageDialog(this,"密码错误"); } else { this.setVisible(false); Frame2 fram2=new Frame2(); fram2.setVisible(true); fram2.setSize(500,500); } }}class Frame1_jButton2_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jButton2_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton2_actionPerformed(e); }}class Frame1_jTextField1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jTextField1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jTextField1_actionPerformed(e); }}class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jButton1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}class Frame1_jPasswordField1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jPasswordField1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jPasswordField1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -