如何为按钮添加事件,新手,请照顾……写的越简单越好~
------解决方案--------------------
button1.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
JOptionPane.showMessageDialog(null,"弹出消息了");
}
});
------解决方案--------------------
Eclipse RCP 4.2版本自带WindowBuilder插件,用设计视图,拖个按钮,双击添加事件。
------解决方案--------------------
提示信息:JOptionPane.showMessageDialog()
------解决方案--------------------
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tt1=t1.getText().toString();
String tt2=t2.getText().toString();
if(tt1.equals("123") && tt2.equals("123"))
{
//Intent intent=new Intent(buju.this,gongneng.class);
JOptionPane.showMessageDialog(jf, "验证成功","提示",0);
jf.setVisible(false);
new gongneng().main(null);
}
else
{
JOptionPane.showMessageDialog(jf,"账号或密码错误","提示",0);
}
}
});
------解决方案--------------------
弹出登录成功或失败的窗口 我是这样做的。当登录成功后 隐藏当前的 JFrame 定义的窗口。也就是jf.setVisibel(false);
然后在载入新窗口也就是定义一个新窗口类然后用他定义一个对象也就织染会出现一个新窗口了 代码为:
new gongneng().main(null);
以上只是我的个人观点。