Results 1 to 7 of 7

Thread: JoptionPane

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Angry 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

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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.....

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  4. #4

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    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

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  6. #6

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    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

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width