i am having little difficulty here with disabling/enabling few JComponents with a checkbox in run-time. I have tried to do if(checkbox.isSelected(){} but it didn’t worked. When i try to add addActionListener(this) i get an error “method addActionListiner in class AbstractButton cannot be applied to given types : required Action listiner: found JudgeMain (its a class name) – leaking “this” in constructor
public class JudgeMain extends JFrame {
Connection conn = null;
ResultSet rs = null;
PreparedStatement pst = null;
LogInJ id = new LogInJ();
public String IdNumber;
public JudgeMain(LogInJ id)
{
initComponents();
ButtonGroup();
this.id = id;
initDetails();
yesCB.addActionListener(this);
if(yesCB.isSelected())
{
timeF.setEnabled(true);
catF.setEnabled(true);
yearsCB.setEnabled(true);
monthsCB.setEnabled(true);
}
}
help appreciated thank you
The class
JudgeMaindoes not represent the typeActionListener.You would need to implement this interface to make it possible to call
or just use an anonymous listener (Note, no need to check the source):
Side Note: The preferred approach is to create an instance of
JFrameand use directly rather than subclassing the class.