/* Main.java
*
* Created on __DATE__, __TIME__
*/
import javax.swing.JOptionPane;
/**
*
* @author __USER__
*/
public class Main extends javax.swing.JFrame {
/** Creates new form Main */
public Main() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel(); //æ ç¾
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton(); //ç»å½æé®
jButton2 = new javax.swing.JButton(); //
jTextField1 = new javax.swing.JTextField(); //ææ¬æ¡
jTextField2 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); //å
³éæ¶çæä½ï¼å³éåºç¨åº
setTitle("ç»å½çé¢"); //设置æ é¢ï¼æ¬¢è¿ä½¿ç¨è¡ç¥¨ç®¡çç³»ç»
setResizable(false); //设置çªå£ä¸å¯è°è大å°
jLabel1.setFont(new java.awt.Font("微软é
é»", 0, 18)); //设置æ ç¾çåä½
jLabel1
.setText("æ¨å¥½ï¼è¯·è¾å
¥ä¿¡æ¯");
jLabel2.setText("
ç¨æ·å");
jLabel3.setText("ç¨æ·å¯ç ");
jButton1.setText("ç»å½");
jButton1.addActionListener(new java.awt.event.ActionListener() { //éç¨å¿åå
é¨ç±»æ¥å®ç°æé®çå¬åè½
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("éåº");
jButton2.addActionListener(new java.awt.event.ActionListener() { //åä¸
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( //å±æ¬¡å¸å±ç®¡çå¨ï¼ä¸é¢né¿ç代ç ï¼å°±æ¯è®¾ç½®ä½ç½®ï¼èªå·±çå§ï¼åµåµï¼è¿ä¸ªå¿
é¡»çï¼å°±ä¸å¤åäº
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout
.setHorizontalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(159, Short.MAX_VALUE)
.addComponent(jLabel1).addGap(140, 140,
140))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addGap(110, 110, 110)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(54, 54, 54)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jTextField2,
javax.swing.GroupLayout.DEFAULT_SIZE,
191,
Short.MAX_VALUE)
.addGap(
112,
112,
112))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
191,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addGap(141, 141, 141)
.addComponent(
jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE,
68,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(89, 89, 89)
.addComponent(
jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE,
72,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(145, Short.MAX_VALUE)));
jPanel1Layout
.setVerticalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(55, 55, 55)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(41, 41, 41)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(48, Short.MAX_VALUE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addContainerGap().addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addContainerGap().addComponent(
jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)));
pack();
setLocationRelativeTo(null); //å±
ä¸
}// </editor-fold>
//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //äºä»¶å¤çï¼ä¸å»ºè®®è¿æ ·å
// TODO add your handling code here:
String name = this.jTextField1.getText().trim(); //è·å¾ç¨æ·åï¼å»ç©ºæ ¼
String password = this.jTextField2.getText().trim(); //è·å¾å¯ç ï¼å»ç©ºæ ¼
if (name.equals("admin") && password.equals("123456")) { //å¦æ符åæ¡ä»¶.....å
¶å®è¿éåºè¯¥å»åæ°æ®åºå
³èï¼è¿æ¯æ»ä»£ç
// Showinformation sf=new Showinformation(); //æ估计æ¯å¦å¤ä¸ä¸ªæ¡æ¶ï¼å°±æ¯ç»å½æåä¹åçæ¡æ¶
// sf.setVisible(true);
// sf.show(); //è¿ä¸ªæ¹æ³å°±ç´æ¥ç§æï¼ä¸ç¨äºï¼å 为sf.setVisible(true)å·²ç»è¢«è°ç¨äºï¼è¿éå°±å¤æ¬¡ä¸ä¸¾äº
} else { //ç¨æ·åæè
å¯ç éªè¯å¤±è´¥
JOptionPane.showMessageDialog(this, "ç¨æ·åæè
å¯ç é误å¦~", "æ示", //æ示æ¡
JOptionPane.INFORMATION_MESSAGE);
this.jTextField1.setText(""); //æ¸
空è¾å
¥æ¡
this.jTextField2.setText("");
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { //äºä»¶å¤çï¼å
¶å®å¯ä»¥å°jButton1ActionPerformedæ¾å¨ä¸èµ·å¤çï¼åªè¦è·å¾æé®çæ ç¾å
容 ï¼JButtonï¼ï¼evt.getSuorse()ï¼.getText()å°±å对æ¯å°±koäº
// TODO add your handling code here:
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() { //好æ¹æ³ï¼åµåµä½¿ç¨è¯¥æ¹å¼çåå æ¯ï¼awtæ¯å线ç¨æ¨¡å¼çï¼ææawtçç»ä»¶åªè½å¨(æ¨èæ¹å¼)äºä»¶å¤ç线ç¨ä¸è®¿é®ï¼ä»èä¿è¯ç»ä»¶ç¶æçå¯ç¡®å®æ§ãjavaæ ¸å¿ç¼ç¨ææ¯ä¸æ¯ä¸ªå®ä¾åºæ¬é½ç¨å°äº
public void run() {
new Main().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;}
// End of variables declaration//GEN-END:variables
ä½ ä¿®æ¹ä¸ä¸å§ï¼ä»è®°äºæ¬è·å¾ç¨æ·åå¤æä¸ä¸å°±è¡äº