I have written a class that extends JCheckBox and am now looking to override the method that gets executed when the check box is clicked. I have tried ‘setSelected’, and ‘doClick’, but neither do as I expect.
Any help is greatly appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s an event-driven model; what you need to do is attach an ItemListener to the checkbox.
See the Swing Tutorials: How to use check boxes.
Your code might look something like this: