|
-
Jan 23rd, 2004, 10:29 PM
#1
Thread Starter
Fanatic Member
JoptionPane
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.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jan 24th, 2004, 01:56 AM
#2
Dazed Member
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.....
-
Jan 24th, 2004, 05:25 AM
#3
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2004, 02:35 PM
#4
Thread Starter
Fanatic Member
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.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jan 25th, 2004, 02:45 PM
#5
Just for you:
http://java.sun.com/j2se/1.4.2/docs/...ptionPane.html
Code:
String str = JOptionPane.showInputDialog("Enter the Celsius value");
double celsius = Double.parseDouble(str);
I gather you know how to convert Celsius to Kelvin
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2004, 06:36 PM
#6
Thread Starter
Fanatic Member
Originally posted by CornedBee
Just for you:
http://java.sun.com/j2se/1.4.2/docs/...ptionPane.html
Code:
String str = JOptionPane.showInputDialog("Enter the Celsius value");
double celsius = Double.parseDouble(str);
I gather you know how to convert Celsius to Kelvin
What libraries do I have to import? And what class do I have to define before calling JOptionPane?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jan 26th, 2004, 09:16 AM
#7
import javax.swing.JOptionPane;
That's all. You don't need to define any special class.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|