Above is what I'm trying do
I have this and it works
switchHLbut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(setBg == true){ switchHLbut.setText("ON"); sbc.setBackground(Color.white); sbc.setText(""); setBg = false; } else if(setBg == false){ switchHLbut.setText("OFF"); sbc.setBackground(Color.yellow); sbc.setText(""); setBg = true; } } });
but I want to call a method within the Action Listener
this was my attempt at calling a method from within the button ActionListenerjbNew.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { System.out.println(" inside jbNew Button"); switchjbNew(); //calling a new method } }); //error:reached end of file while parsing public void switchjbNew() //error: illegal start of expression missing javadoc { System.out.println("inside switchjbNew"); }
Failed