請參閱下面的codem我想叫成功登錄後JMenu類中如何在Java擺動successfulley登錄後調用JMenu的屏幕
登錄:
public class Login {
Connection con;
Statement st;
ResultSet rs;
JFrame f = new JFrame ("User Login");
JLabel l = new JLabel ("UserName:");
JLabel l1 = new JLabel ("Password:");
JTextField t = new JTextField (10);
JTextField t1 = new JTextField (10);
JButton b = new JButton ("Login");
public Login()
{
connect();
frame();
}
public void connect()
{
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String db = "jdbc:odbc:Joy_DB";
con = DriverManager.getConnection(db);
st = con.createStatement();
}
catch (Exception ex)
{
}
}
public void frame()
{
f.setSize (600,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible (true);
JPanel p = new JPanel();
p.add (l);
p.add (t);
p.add (l1);
p.add (l);
p.add (t1);
p.add (b);
f.add (p);
b.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e)
{
try
{
String user = t.getText(). trim();
String pass = t1.getText(). trim();
String sql = "select User,Password from Table2 where User = '"+user+"' and Password = '"+pass+"'";
rs = st.executeQuery(sql);
int count = 0;
while (rs.next())
{
count = count +1;
}
if (count == 1)
{
JOptionPane.showMessageDialog(null,"User Found");
//JMenuDemo M = new JMenuDemo();
}
else if (count > 1)
{
JOptionPane.showMessageDialog(null, "Duplicate User !");
}
else
{
JOptionPane.showMessageDialog (null,"User does not exist");
}
}
catch (Exception ex)
{
}
}
});
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Login();
//JMenuDemo M = new JMenuDemo();
// TODO code application logic here
}
}
我怎樣才能調用成功後Ĵ菜單框登錄使用上述codem
請幫 我會派其他類,這是保險業監督JMenu的一段時間
JMenu的代碼是如下 – user2351538 2013-05-05 09:18:05
@esseks不要在評論後編輯總結獲取信息,也沒用。 – Flawyte 2013-05-05 09:24:11
你說得對。刪除了評論。 – 2013-05-05 09:27:45