Can I make anonymous event handler method to act conditional like
JButton activeDataBtn = new JButton("Active");
activeDataBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
if (activeDataPanel.setVisible(false)) { //Erroneous code
readDataFromFile(); //a method reads data from .csv
//file and shows it on activeDataPanel
activeDataPanel.setVisible(true);
}
else
activeDataPanel.setVisible(false);
}
}
});
how can i make this conditional?