回覆列表
  • 1 # 平章芯事

    寫出來需要一個月,理解需要半年,熟練需要至少一年,你確定你老師想要你?

    tomcat + jsp(或者servlet) + jdbc + mysql。

    這是最簡單的技術路徑了。

    有更快捷的方式,如jfinal和spring boot,但你根本不知道原理,估計還沒這個得心應手。

  • 2 # 使用者59855945091

    import javax.swing.JFrame;//框架import javax.swing.JPanel;//面板import javax.swing.JButton;//按鈕import javax.swing.JLabel;//標籤import javax.swing.JTextField;//文字框import java.awt.Font;//字型import java.awt.Color;//顏色import javax.swing.JPasswordField;//密碼框import java.awt.event.ActionListener;//事件監聽import java.awt.event.ActionEvent;//事件處理import javax.swing.JOptionPane;//訊息視窗public class UserLogIn extends JFrame{ public JPanel pnluser; public JLabel lbluserLogIn; public JLabel lbluserName; public JLabel lbluserPWD; public JTextField txtName; public JPasswordField pwdPwd; public JButton btnSub; public JButton btnReset; public UserLogIn(){ pnluser = new JPanel(); lbluserLogIn = new JLabel(); lbluserName = new JLabel(); lbluserPWD = new JLabel(); txtName = new JTextField(); pwdPwd = new JPasswordField(); btnSub = new JButton(); btnReset = new JButton(); userInit(); } public void userInit(){ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設定關閉框架的同時結束程式 this.setSize(300,200);//設定框架大小為長300,寬200 this.setResizable(false);//設定框架不可以改變大小 this.setTitle("使用者登入");//設定框架標題 this.pnluser.setLayout(null);//設定面板佈局管理 this.pnluser.setBackground(Color.cyan);//設定面板背景顏色 this.lbluserLogIn.setText("使用者登入");//設定標籤標題 this.lbluserLogIn.setFont(new Font("宋體",Font.BOLD | Font.ITALIC,14));//設定標籤字型 this.lbluserLogIn.setForeground(Color.RED);//設定標籤字型顏色 this.lbluserName.setText("使用者名稱:"); this.lbluserPWD.setText("密 碼:"); this.btnSub.setText("登入"); this.btnReset.setText("重置"); this.lbluserLogIn.setBounds(120,15,60,20);//設定標籤x座標120,y座標15,長60,寬20 this.lbluserName.setBounds(50,55,60,20); this.lbluserPWD.setBounds(50,85,60,25); this.txtName.setBounds(110,55,120,20); this.pwdPwd.setBounds(110,85,120,20); this.btnSub.setBounds(85,120,60,20); this.btnSub.addActionListener(new ActionListener()//匿名類實現ActionListener介面 { public void actionPerformed(ActionEvent e){ btnsub_ActionEvent(e); } } ); this.btnReset.setBounds(155,120,60,20); this.btnReset.addActionListener(new ActionListener()//匿名類實現ActionListener介面 { public void actionPerformed(ActionEvent e){ btnreset_ActionEvent(e); } } ); this.pnluser.add(lbluserLogIn);//載入標籤到面板 this.pnluser.add(lbluserName); this.pnluser.add(lbluserPWD); this.pnluser.add(txtName); this.pnluser.add(pwdPwd); this.pnluser.add(btnSub); this.pnluser.add(btnReset); this.add(pnluser);//載入面板到框架 this.setVisible(true);//設定框架可顯 } public void btnsub_ActionEvent(ActionEvent e){ String name = txtName.getText(); String pwd = String.valueOf(pwdPwd.getPassword()); if(name.equals("")){ JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE); return; }else if (pwd.equals("")){ JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE); return; }else if(true){ this.dispose(); }else{ JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE); return; } } public void btnreset_ActionEvent(ActionEvent e){ txtName.setText(""); pwdPwd.setText(""); } public static void main(String[] args){ new UserLogIn(); }}

  • 中秋節和大豐收的關聯?
  • 西周穆王時期的西王母國是否就是東周秦漢時期的大月氏?