How to disable javax.swing.JButton in java?

前端 未结 3 836
失恋的感觉
失恋的感觉 2020-12-15 04:25

I have created a swings application and there is a \"Start\" button on the GUI. I want that whenever I clicked on that \"Start\" button, the start button should be disabled

3条回答
  •  天命终不由人
    2020-12-15 05:01

    The code is very long so I can't paste all the code.

    There could be any number of reasons why your code doesn't work. Maybe you declared the button variables twice so you aren't actually changing enabling/disabling the button like you think you are. Maybe you are blocking the EDT.

    You need to create a SSCCE to post on the forum.

    So its up to you to isolate the problem. Start with a simple frame thas two buttons and see if your code works. Once you get that working, then try starting a Thread that simply sleeps for 10 seconds to see if it still works.

    Learn how the basice work first before writing a 200 line program.

    Learn how to do some basic debugging, we are not mind readers. We can't guess what silly mistake you are doing based on your verbal description of the problem.

提交回复
热议问题