java swing 我做了一个JFrame页面点击按钮连接到另一个页面时,为什么连接的页面不是我最新的呢?
点击btnLogin进入useServeFrame页面btnLogin.setBounds(newRectangle(78,150,86,30));btnLogin.ad...
点击btnLogin 进入useServeFrame页面
btnLogin.setBounds(new Rectangle(78, 150, 86, 30));
btnLogin.addActionListener(this);
……
public void actionPerformed(ActionEvent evt) {
Object obj = evt.getSource();
JTextField txtusername = Registe.getTxtUserName();
String username = txtusername.getText();
JTextField txtuserpassword = Registe.getTxtUserPassword();
String password = txtuserpassword.getText();
try {
if(obj==btnLogin){
String sqlstr="select * from usertable where username='"+username+"' and userpassword='"+password+"'";
//执行查询操作
ResultSet rs = op1.query(sqlstr);
while(rs.next()){
for(int i=1;i<=4;i++){
if(!rs.getString(i).isEmpty()){
UseServeFrame useServeFrame = new UseServeFrame();
useServeFrame.pack();
useServeFrame.show();
}
}
……
}
}else{System.exit(0);}
} catch (Exception e) {
System.out.println("error:"+e);
}
} 展开
btnLogin.setBounds(new Rectangle(78, 150, 86, 30));
btnLogin.addActionListener(this);
……
public void actionPerformed(ActionEvent evt) {
Object obj = evt.getSource();
JTextField txtusername = Registe.getTxtUserName();
String username = txtusername.getText();
JTextField txtuserpassword = Registe.getTxtUserPassword();
String password = txtuserpassword.getText();
try {
if(obj==btnLogin){
String sqlstr="select * from usertable where username='"+username+"' and userpassword='"+password+"'";
//执行查询操作
ResultSet rs = op1.query(sqlstr);
while(rs.next()){
for(int i=1;i<=4;i++){
if(!rs.getString(i).isEmpty()){
UseServeFrame useServeFrame = new UseServeFrame();
useServeFrame.pack();
useServeFrame.show();
}
}
……
}
}else{System.exit(0);}
} catch (Exception e) {
System.out.println("error:"+e);
}
} 展开
3个回答
展开全部
如果东西不大的话,发我邮箱
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
搞不懂你的问题。能把监听的代码贴上来吗?
追问
try {
if(obj==btnLogin){
String sqlstr="select * from usertable where username='"+username+"' and userpassword='"+password+"'";
//执行查询操作
ResultSet rs = op1.query(sqlstr);
while(rs.next()){
for(int i=1;i<=4;i++){
if(!rs.getString(i).isEmpty()){
UseServeFrame useServeFrame = new UseServeFrame();
useServeFrame.pack();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询