Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to use ActionListener to open a class file?

terryfreedomterryfreedom Posts: 9Member
public void actionPerformed(ActionEvent e)
{

if(e.getSource()== open)
{
Graph app=new Graph();
}
}
There is an error after compling. This is the comment.

C:Documents and Settingsstudent18aMy DocumentsJava ProjectColorSelect.java:55: unreported exception java.io.IOException; must be caught or declared to be thrown
Graph app=new Graph();
^
1 error

Any ways to solve this error to open this class file called "Graph"? Thanks to the personal who provide solutions.

Comments

  • zibadianzibadian Posts: 6,349Member
    : public void actionPerformed(ActionEvent e)
    : {
    :
    : if(e.getSource()== open)
    : {
    : Graph app=new Graph();
    : }
    : }
    : There is an error after compling. This is the comment.
    :
    : C:Documents and Settingsstudent18aMy DocumentsJava ProjectColorSelect.java:55: unreported exception java.io.IOException; must be caught or declared to be thrown
    : Graph app=new Graph();
    : ^
    : 1 error
    :
    : Any ways to solve this error to open this class file called "Graph"? Thanks to the personal who provide solutions.
    :
    :
    Either import a package containing the Graph class, or define the Graph class yourself.
  • terryfreedomterryfreedom Posts: 9Member
    : : public void actionPerformed(ActionEvent e)
    : : {
    : :
    : : if(e.getSource()== open)
    : : {
    : : Graph app=new Graph();
    : : }
    : : }
    : : There is an error after compling. This is the comment.
    : :
    : : C:Documents and Settingsstudent18aMy DocumentsJava ProjectColorSelect.java:55: unreported exception java.io.IOException; must be caught or declared to be thrown
    : : Graph app=new Graph();
    : : ^
    : : 1 error
    : :
    : : Any ways to solve this error to open this class file called "Graph"? Thanks to the personal who provide solutions.
    : :
    : :
    : Either import a package containing the Graph class, or define the Graph class yourself.
    :

  • terryfreedomterryfreedom Posts: 9Member
    : : : public void actionPerformed(ActionEvent e)
    : : : {
    : : :
    : : : if(e.getSource()== open)
    : : : {
    : : : Graph app=new Graph();
    : : : }
    : : : }
    : : : There is an error after compling. This is the comment.
    : : :
    : : : C:Documents and Settingsstudent18aMy DocumentsJava ProjectColorSelect.java:55: unreported exception java.io.IOException; must be caught or declared to be thrown
    : : : Graph app=new Graph();
    : : : ^
    : : : 1 error
    : : :
    : : : Any ways to solve this error to open this class file called "Graph"? Thanks to the personal who provide solutions.
    : : :
    : : :
    : : Either import a package containing the Graph class, or define the Graph class yourself.
    : :
    What u mean import package contain the Graph class? Can give examples? Thanks.

  • zibadianzibadian Posts: 6,349Member
    : : : : public void actionPerformed(ActionEvent e)
    : : : : {
    : : : :
    : : : : if(e.getSource()== open)
    : : : : {
    : : : : Graph app=new Graph();
    : : : : }
    : : : : }
    : : : : There is an error after compling. This is the comment.
    : : : :
    : : : : C:Documents and Settingsstudent18aMy DocumentsJava ProjectColorSelect.java:55: unreported exception java.io.IOException; must be caught or declared to be thrown
    : : : : Graph app=new Graph();
    : : : : ^
    : : : : 1 error
    : : : :
    : : : : Any ways to solve this error to open this class file called "Graph"? Thanks to the personal who provide solutions.
    : : : :
    : : : :
    : : : Either import a package containing the Graph class, or define the Graph class yourself.
    : : :
    : What u mean import package contain the Graph class? Can give examples? Thanks.
    :
    :
    I don't know which package defines the Graph class, so I cannot give you the specific code, but here are some examples:
    [code]
    import javax.swing.*;
    import java.io.*;
    import java.awt.event.*;
    import schets.gui.dialogs.*;
    import schets.io.*;
    [/code]
Sign In or Register to comment.