我正在處理某些事情,我需要從其他函數調用actionlistner
禁用的jbutton
。如何做到這一點?呼叫被禁用的動作偵聽員JButton
回答
不能呼叫/做actions
上disabled
GUI controls.That實際上是disable
意味着什麼
你可以做的是創建一個單獨的常用方法類似doClick()
,並呼籲在任何你需要的。
製作一個新的方法,這個方法將被禁用的jbutton調用,寫下所有的代碼,當你點擊按鈕時將會執行這些代碼。您不能以其他方式致電actionlistiner
。
...
JButton disButton = new JButton("Disabled");
disButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
//do not write any statement here
doSomething();
}
});
...
private void doSomething() {
//all action event execution code here
System.out.println("I am in the action listener");
}
....
//in the other method or another button click event call doSomething()
//even button is disables like
JButton Button = new JButton("Submit");
Button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
doSomething();
}
});
//or from another method
public void method() {
doSomething();
}
+1爲實現:) –
其實在創建的JButton我需要固定的某些參數在它的行動所進行的方法有哪些不是靜態的,所以我根本無法調用另一種方法 – avinash
在被調用的函數中修復這些參數,或者將其從預先形成的操作中傳遞出來。 –
- 1. JTextArea吞嚥JButton動作偵聽器Java
- 2. 從一個單獨的類中的偵聽器中禁用JButton
- 3. Node.js偵聽EADDRNOTAVAIL使用ipaddress共享pc呼叫
- 4. Luaj - 從Lua添加JButton動作偵聽器
- 5. RingOut和呼叫記錄結果無用(當呼叫未被人接聽時)
- 6. C#Outlook - 呼叫被拒絕的呼叫
- 7. JButton動作監聽器
- 8. 推出從偵聽呼出
- 9. 呼叫事件偵聽器background.js內容腳本
- 10. 在onReceive()偵聽之前取消註冊廣播呼叫
- 11. CKEditor - 添加自定義事件偵聽器並呼叫原始
- 12. 爲什麼我的動作偵聽器不叫
- 13. 禁止呼叫System.exit
- 14. Java - JButton偵聽器不觸發
- 15. 呼叫操作員的衍生自
- 16. 在谷歌地圖中被遞歸調用的聽衆呼叫
- 17. 星號AMI - 接聽呼叫
- 18. Android呼叫狀態偵聽程序在一段時間後停止工作
- 19. JButton的鼠標移動偵聽器的小信息幀(提示)
- 20. 鼠標偵聽器和動作偵聽器的區別?
- 21. 想聽聽來電和撥出呼叫
- 22. 呼叫通過AJAX的動作偵聽器,當用戶按下啊輸入:表單輸入字段
- 23. 呼叫行動被點擊的形式
- 24. Android使偵聽onClickListener的禁用按鈕
- 25. JButton數組的動作監聽器
- 26. 呼叫控制器動作
- 27. 角度2和被動偵聽器
- 28. 收到呼叫時的呼叫動作android
- 29. 在動作偵聽器偵聽事件後,Java gui不打印
- 30. 偵聽啓用/禁用狀態更改
感謝助理的辦法是給予好評/接受他們的崗位/ s的:-) – kleopatra