展开全部
按照你的代码,最简单但笨拙的解决方32313133353236313431303231363533e59b9ee7ad9431333335333139案如下://method reco
JPasswordFieldDemo JP=new JPasswordFieldDemo();
String reader_id = null;
do{
reader_id=JP.reader_id;
int n1=0;
//后续登陆check逻辑
}while(reader_id!=null);
最好的做法是给登陆窗口中的登陆按钮触发事件时调用后续的登陆查询逻辑//method reco
//1.实例化登陆窗口对象
JPasswordFieldDemo JP=new JPasswordFieldDemo();//构造是不要立即显示窗体
//2.注册事件
JButton loginBtn=JP.getLoginButton();//简单封装下,当然可以粗糙些,类似 JP.reader_id
//注册一个listener
loginBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//后续登陆check逻辑
}
});
//3.显示登陆窗口
JP.setVisible(true);
看了下,你说好像去登陆框里的值有问题,取不到,可以这样封装个方法在类JPasswordFieldDemo//类JPasswordFieldDemo中定义一个方法
public String getLoginName(){
//用户名控件 nameTextField
return nameTextFiled.getText();
}
//密码控件也可以类似
然后在当前类中recommend中
String reader_id=JP.reader_id 改成
String reader_id=JP.getLoginName();
类似这种