🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by DementiaT Sat, 20 Dec 2003 09:08
How do you have the user input an integer using JOptionPane.showInputDialog
#1409
Author: DementiaT
Date: Sat, 20 Dec 2003 09:08
19 lines
1862 bytes
Beginner here :)

Im trying to do just that...have the user enter an integer into the
dialog box...

my code is:
...

int invQty;

invQty = JOptionPane.showInputDialog (null, "What is the quantity of
\"" + invName + "\"?","Enter Quantity", JOptionPane.QUESTION_MESSAGE);

...

I get an incompatible type error...  it seems
JOptionPane.showInputDialog  only accepts strings?

Thanks :)
Re: How do you have the user input an integer using JOptionPane.showInputDialog
#1410
Author: Craig Simmons
Date: Sat, 20 Dec 2003 14:49
40 lines
2343 bytes
Hi

What you want to do is...

int invQty;
String retValue =  JOptionPane.showInputDialog (null, "What is the quantity
of
\"" + invName + "\"?","Enter Quantity", JOptionPane.QUESTION_MESSAGE);

try{
    invQty = Interger.parseInt(retValue);
catch(NumberFormatException x){
    //handle error
   }

Craig

"DementiaT" <dementiat@high.net> wrote in message
news:o548uvshiobdff6str8j1rgvc5o25oqd3f@4ax.com...
: Beginner here :)
:
: Im trying to do just that...have the user enter an integer into the
: dialog box...
:
: my code is:
: ...
:
: int invQty;
:
: invQty = JOptionPane.showInputDialog (null, "What is the quantity of
: \"" + invName + "\"?","Enter Quantity", JOptionPane.QUESTION_MESSAGE);
:
: ...
:
: I get an incompatible type error...  it seems
: JOptionPane.showInputDialog  only accepts strings?
:
: Thanks :)
:
:
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads