shenfen.addItemListener(new ItemListener(){
String name=shenfen.getSelectedItem();
// int index=shenfen.getSelectedIndex();
if(name.equals("------------------超级管理员----------------------"){
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String id = ID.getText();
String psw = String.valueOf(password.getPassword());
if(checkLogin(id,psw)){
jf.dispose();
boolean packFrame = false;
Splash frame = new Splash();
if(packFrame){
frame.pack();
}
else{
frame.validate();
}
Dimension screenSize1 = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize1 = frame.getSize();
if(frameSize1.height > screenSize1.height){
frameSize1.height = screenSize1.height;
}
if(frameSize1.width > screenSize1.width){
frameSize1.width = screenSize1.width;
}
frame.setLocation((screenSize1.width - frameSize1.width)/2,(screenSize1.height - frameSize1.height)/2);
frame.show();
}
else{
JOptionPane.showMessageDialog(null,"密码错误");
}
}
public boolean checkLogin(String Id,String Psw){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:YaoFang";
Connection conn = DriverManager.getConnection(url,"cenjuhui","123");
PreparedStatement stmt;
stmt = conn.prepareStatement("select * from [User] Where S_ID=? AND S_PSW=?");//注意把User 写成[User],避免数据库的关键字
stmt.setString(1,Id);
stmt.setString(2,Psw);
ResultSet rs = stmt.executeQuery();
while(rs.next()){
return true;
}
while(rs.next()==false){
JOptionPane.showMessageDialog(null,"帐号或密码不存在!请重新输入!");
return false;
}
rs.close();
stmt.close();
conn.close();
}catch(ClassNotFoundException e){
System.out.println("找不到指定的驱动程序类!");
}catch(SQLException e){
e.printStackTrace();
}return false;
}
}
);
}
这是一个带权限的登陆按钮,老提示非法类型的开始,需要标识符...难道内部类里面就不能再有内部类吗?
String name=shenfen.getSelectedItem();
// int index=shenfen.getSelectedIndex();
if(name.equals("------------------超级管理员----------------------"){
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String id = ID.getText();
String psw = String.valueOf(password.getPassword());
if(checkLogin(id,psw)){
jf.dispose();
boolean packFrame = false;
Splash frame = new Splash();
if(packFrame){
frame.pack();
}
else{
frame.validate();
}
Dimension screenSize1 = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize1 = frame.getSize();
if(frameSize1.height > screenSize1.height){
frameSize1.height = screenSize1.height;
}
if(frameSize1.width > screenSize1.width){
frameSize1.width = screenSize1.width;
}
frame.setLocation((screenSize1.width - frameSize1.width)/2,(screenSize1.height - frameSize1.height)/2);
frame.show();
}
else{
JOptionPane.showMessageDialog(null,"密码错误");
}
}
public boolean checkLogin(String Id,String Psw){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:YaoFang";
Connection conn = DriverManager.getConnection(url,"cenjuhui","123");
PreparedStatement stmt;
stmt = conn.prepareStatement("select * from [User] Where S_ID=? AND S_PSW=?");//注意把User 写成[User],避免数据库的关键字
stmt.setString(1,Id);
stmt.setString(2,Psw);
ResultSet rs = stmt.executeQuery();
while(rs.next()){
return true;
}
while(rs.next()==false){
JOptionPane.showMessageDialog(null,"帐号或密码不存在!请重新输入!");
return false;
}
rs.close();
stmt.close();
conn.close();
}catch(ClassNotFoundException e){
System.out.println("找不到指定的驱动程序类!");
}catch(SQLException e){
e.printStackTrace();
}return false;
}
}
);
}
这是一个带权限的登陆按钮,老提示非法类型的开始,需要标识符...难道内部类里面就不能再有内部类吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货