I want a button ("closeButton") to grey out when the function "openExplanations" run. But it is not working.
Gives error Cannot invoke "javax.swing.JButton.setEnabled(boolean)" because "this.closeButton" is null
//the UI
private void initUI() {
hintArea = new JDialog(this);
buttonsPanel = new JPanel();
buttonsPanel.setAlignmentX(0.0f);
JButton closeButton = new JButton(" Close Hint ");
closeButton.setActionCommand("closeHint");
closeButton.setVisible(true);
closeButton.addActionListener(this);
closeButton.setFocusable(false);
closeButton.setIcon(createImageIcon("images/constraint/close.gif"));
buttonsPanel.add(closeButton, BorderLayout.WEST);
hintArea.add(buttonsPanel, BorderLayout.CENTER);
}
private void openExplanation(){
closeButton.setEnabled(false);
}