?? login.java
字號:
package good;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.*;
public class Login extends JFrame implements ActionListener{
private static final int CENTER = 0;
/**
* @param args
*/
String user="1";
String pass="1";
protected static int check;
public Login()
{
Container container=this.getContentPane();
JPanel staticPanel=new JPanel(new GridLayout(2,2),true);
JPanel staticPanel1=new JPanel(new FlowLayout(),true);
JLabel userL= new JLabel("用戶名稱",CENTER);
JLabel passwordL= new JLabel("密碼",CENTER);
final JTextField userField=new JTextField("",10);
final JTextField passwordField=new JTextField("",10);
JButton okButton=new JButton("確定");
JButton cancelButton=new JButton("取消");
//jj.getContentPane().add(container);
container.add(staticPanel,"Center");
container.add(staticPanel1,"South");
staticPanel.add(userL);
staticPanel.add(userField);
staticPanel.add(passwordL);
staticPanel.add(passwordField);
staticPanel1.add(okButton);
staticPanel1.add(cancelButton);
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated meithod stub
if (userField.getText().trim().compareTo(user)==0 && passwordField.getText().trim().compareTo(pass)==0 )
{
setMemu();
dispose();
}
else
{
check=0;
JOptionPane.showConfirmDialog(Login.this,"密碼或用戶名錯誤","提示",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE );
}
dispose();
}
});
cancelButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
dispose();
}
});
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e){
dispose();
}});
this.setSize(200,150);
this.setBounds(0,50,200,120);
this.show();
}
public void setMemu()
{
Mainframe.employeeMenu.setEnabled( true);
Mainframe.clientMenu.setEnabled( true);
Mainframe.imanufacturerMenu.setEnabled( true);
Mainframe.goodmodiItem.setEnabled( true);
Mainframe.goodaddItem .setEnabled( true);
Mainframe.ioItem .setEnabled( true);
Mainframe.goodsdeleItem .setEnabled( true);
}
public void actionPerformed(ActionEvent actionEvent) {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -