Action Event help
Hi, I've created a GUI program that has JButtons for like a menu. I am trying to get the action listener to do a whole other method.
EXample:
view.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
menu();
System.exit(0);
}
But, It will not go to the method. It displays an error message that says: "unreported exception java.io.IOException; must be caught or declared to be thrown"
I am unsure if I must throw an IOException, or even how to throw and actionListener.
joshSCH
Industrious Poster
4,864 posts since Jul 2005
Reputation Points: 1,315
Solved Threads: 10
catch the exception:
public void actionPerformed(ActionEvent ae)
{
try
{
methodcall();
}
catch(IOException ioe)
{
}
}
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
that worked perfectly!! thanks
joshSCH
Industrious Poster
4,864 posts since Jul 2005
Reputation Points: 1,315
Solved Threads: 10
that worked perfectly!! thanks
No problem, just glad to help! ;)
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20