Results 1 to 1 of 1
Thread: IOException error
- 08-29-2009, 09:02 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 3
- Rep Power
- 0
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
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");
}
}
Similar Threads
-
[SOLVED] IOException
By sfe23 in forum New To JavaReplies: 11Last Post: 02-20-2009, 10:36 PM -
Error: unreported exception java.io.IOException; ??
By jonsamwell in forum New To JavaReplies: 5Last Post: 08-24-2008, 04:11 AM -
GUI IOException
By serfster in forum New To JavaReplies: 3Last Post: 06-13-2008, 04:19 AM -
java.io.IOException: CreateProcess: matlab error=2
By Jack in forum Advanced JavaReplies: 3Last Post: 04-10-2008, 09:01 AM -
Variable passing, Error: IOException
By fernando in forum New To JavaReplies: 3Last Post: 07-31-2007, 02:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks