📄 welcome.java
字号:
/* * Welcome.java * * Created on 2008年5月7日, 下午6:42 */package javaproject;import javax.swing.ImageIcon;import java.io.*;import javax.swing.JOptionPane;/** * * @author Tian Fengping */public class Welcome extends javax.swing.JFrame { /** Creates new form Welcome */ public Welcome() { 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { welcomeJLabel = new javax.swing.JLabel(); firstOKJButton = new javax.swing.JButton(); allJPasswordField = new javax.swing.JPasswordField(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Welcome"); welcomeJLabel.setIcon(new ImageIcon("imags/welcome.gif")); firstOKJButton.setText("确定"); firstOKJButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { firstOKJButtonActionPerformed(evt); } }); jLabel1.setText("Enter Password:"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(187, 187, 187) .addComponent(firstOKJButton, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) .addGap(154, 154, 154)) .addGroup(layout.createSequentialGroup() .addGap(67, 67, 67) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE) .addComponent(allJPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(18, Short.MAX_VALUE) .addComponent(welcomeJLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 422, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(welcomeJLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(allJPasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(firstOKJButton) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void firstOKJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firstOKJButtonActionPerformed // TODO add your handling code here: File passwordFile; BufferedReader output; String oldPassword=""; try { passwordFile = new File("Password.dat"); FileReader inputFile = new FileReader(passwordFile); output=new BufferedReader(inputFile); oldPassword=output.readLine(); } catch (IOException ex) { JOptionPane.showMessageDialog(null,"Make sure your input!"); } if(String.valueOf(allJPasswordField.getPassword()).equals(oldPassword)) { this.setVisible(false); OperationFrame mainFrame=new OperationFrame(); mainFrame.setVisible(true); mainFrame.setLocationRelativeTo(null); } else { JOptionPane.showMessageDialog(null,"The password is wrong","Wrong Pssword!",JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_firstOKJButtonActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Welcome().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPasswordField allJPasswordField; private javax.swing.JButton firstOKJButton; private javax.swing.JLabel jLabel1; private javax.swing.JLabel welcomeJLabel; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -