我正在尝试将新客户菜单对话框绑定(bind)到应用程序中的 newCustomer 按钮。有什么想法吗?
最佳答案
要在 java 中绑定(bind)操作,您需要添加 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.
}
});
关于java - Swing 将对话框绑定(bind)到 JButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/957288/