How do you make InputBoxes in Java??
i tried:
class A{
public static void main(String[] args){
double F = JOptionPane.showInputBox("Input");
}}
Doesn't work...
help.
Printable View
How do you make InputBoxes in Java??
i tried:
class A{
public static void main(String[] args){
double F = JOptionPane.showInputBox("Input");
}}
Doesn't work...
help.
All you need to do is find the right static method to call. There is a large amount of static dialog display methods that can be invoked which enable you to display a dialog with messages, icons, JButtons ect ect.....
None of them returns a double though, even the input box returns a string. You must do the conversion afterwards, e.g. with Float.parseFloat, or Double.parseDouble.
Quote:
Originally posted by Dilenger4
All you need to do is find the right static method to call. There is a large amount of static dialog display methods that can be invoked which enable you to display a dialog with messages, icons, JButtons ect ect.....
I'm totally lost lol... The teacher told us to write a program that prompts user for the input of Celsius and then we need to let program convert Celsius inputed to Kelvin. I don't know if there is anything else can be done to achieve input. Btw, is not applet.
Just for you:
http://java.sun.com/j2se/1.4.2/docs/...ptionPane.html
I gather you know how to convert Celsius to Kelvin ;)Code:String str = JOptionPane.showInputDialog("Enter the Celsius value");
double celsius = Double.parseDouble(str);
Quote:
Originally posted by CornedBee
Just for you:
http://java.sun.com/j2se/1.4.2/docs/...ptionPane.html
I gather you know how to convert Celsius to Kelvin ;)Code:String str = JOptionPane.showInputDialog("Enter the Celsius value");
double celsius = Double.parseDouble(str);
What libraries do I have to import? And what class do I have to define before calling JOptionPane?
import javax.swing.JOptionPane;
That's all. You don't need to define any special class.