Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue with IOException and actionPerformed method

843807Mar 17 2010 — edited Mar 18 2010
Hi there,

I have a Java application that reads some information from a file on the file system.

It is really basic, I have some info on the application that the user enter and then the user hits a button. From there the application calls a new class that does some IO from a file and then returns.

However, the actionPerformed method I am using does not seem to allow IOExceptions here is a sample:
import javax.swing.*;
import java.awt.event.*;
import java.io.*;

public class mainWindow implements ActionListener
{
   JButton go = new JButton("Go");

  public void actionPerformed(ActionEvent e)
  {
        //This loads my IO class
        doIO getInfo = new doIO( );

   public mainWindow
   {
       //does all the mainWindow things
       go.addActionListener(this);
   }
}
That is basically my window that calls the other class, obviously there is a lot of fundametals missing but the main problem is in the actionPerformed method.
When I try and do that I get the error "Unhandled Exception type IOException"

This is where the problem gets a little wierd, my class doIO looks something like this:
import java.io.*;

public class doIO
{
   public doIO ( ) throws IOExcpetion
   {
      //All my Io Stuff
   }
{
Since the method actionPerformed in part of the Interface ActionListener I cannot use the "throws IOException" on that method.


Any suggestions?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2010
Added on Mar 17 2010
2 comments
470 views