我正在尝试将新的客户菜单对话框绑定到我的应用程序中的 newCustomer 按钮。有任何想法吗?
问问题
1878 次
3 回答
2
那么在java中绑定动作你添加ActionListener
s。
构建按钮时,您需要向其添加 ActionListener。这样,当点击事件发生时,按钮就知道该做什么了。
newCustomerButon.add(new ActionListener(){
public void actionPerformed(ActionEvent e){
// This is where you put the code for popping up the form.
yourForm.setVisible(true); // Or something similar.
}
});
于 2009-06-05T18:18:22.183 回答
0
JButton newCustomer = new JButton();
newCustomer.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
// TODO bind the new customer menu dialog box
}
});
于 2009-06-10T21:19:41.517 回答
0
据我所知,有几个 add() 方法是从 Component 继承的,但没有一个会将 ActionListener 添加到 JButton。你的意思是addActionListener()吗?
于 2009-06-05T18:41:22.800 回答