Results 1 to 1 of 1
  1. #1
    eeraj is offline Member
    Join Date
    Aug 2009
    Posts
    3
    Rep Power
    0

    Default IOException error

    well i am a newbie in java programming...i want to make a frame and button display program in which when the button is clicked then it prompts user to enter the value...but i am getting a exception throw error..i dont know exactly where to place the file " throws IOException" in code...plzzzzzzzzzzz help me out
    here is the code

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    
    class ButtonFrame extends Frame
       
      implements ActionListener , WindowListener 
    {  
       Button button;
       Button button1;
       Button button2;
       Button button3;
       double l,w,h;
       ButtonFrame(String s)
      {  super(s);
       setBackground(Color.magenta);
       setSize(500,400);
       setLayout(new FlowLayout());
       addWindowListener(this);
       button = new Button("Length");
       button1= new Button("Width");
       button2 = new Button("Height");
       button3 = new Button("Volume");
       add(button);
       add(button1);
       add(button2);
       add(button3);
       button.addActionListener(this);  
       button1.addActionListener(this);
       button2.addActionListener(this);
       button3.addActionListener(this);
       setVisible(true);
      }
    
    public void windowClosed(WindowEvent event){}
    public void windowDeiconified(WindowEvent event){}
    public void windowIconified (WindowEvent event){}
    public void windowActivated(WindowEvent event){}
    public void windowDeactivated(WindowEvent event){}
    public void windowOpened(WindowEvent event){}
    
    public void windowClosing(WindowEvent event)
      {   System.exit(0);
      }
    
    public void actionPerformed(ActionEvent event)  
     {  if  (event.getActionCommand().equals("Length"))
         
         {  
            InputStreamReader reader = new InputStreamReader(System.in);
            BufferedReader input = new BufferedReader (reader);
            System.out.println("Enter Length:");
            String text= input.readLine();
            Double x = new Double(text);
            l = x.doubleValue();
         }
    
         if  (event.getActionCommand().equals("Width")) 
         
        {  
           InputStreamReader reader = new InputStreamReader(System.in);
           BufferedReader input = new BufferedReader (reader);
           System.out.println("Enter Width:");
           String text= input.readLine();
           Double x = new Double(text);
            w = x.doubleValue();
         }
    
         if  (event.getActionCommand().equals("Height"))
          
          { 
            InputStreamReader reader = new InputStreamReader(System.in);
            BufferedReader input = new BufferedReader (reader);
            System.out.println("Enter Height:");
            String text= input.readLine();
            Double x = new Double(text);
             h = x.doubleValue();
          }    
          if  (event.getActionCommand().equals("Volume"))
         { System.out.println("The Volume of Figure ");
          
           Double volume = l*w*h;
           System.out.println("is" +volume);
         }
     }
    }
    
    
    class TestButtonFrame2
    {  public static void main (String[] args)
       { ButtonFrame buttonFrame = new ButtonFrame("Volume Calculator");
       }
    }
    Last edited by Fubarable; 08-29-2009 at 01:28 PM. Reason: Code tags added for readability

Similar Threads

  1. IOException error
    By eeraj in forum AWT / Swing
    Replies: 0
    Last Post: 08-29-2009, 09:02 AM
  2. Error: unreported exception java.io.IOException; ??
    By jonsamwell in forum New To Java
    Replies: 5
    Last Post: 08-24-2008, 04:11 AM
  3. GUI IOException
    By serfster in forum New To Java
    Replies: 3
    Last Post: 06-13-2008, 04:19 AM
  4. Replies: 3
    Last Post: 04-10-2008, 09:01 AM
  5. Variable passing, Error: IOException
    By fernando in forum New To Java
    Replies: 3
    Last Post: 07-31-2007, 02:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •