JOptionPane needs help

S

shoa

Hello
I have a JOptionPane that allow me select an object (inside a vector
"allPeople"). After selecting an object in this JOptionPane, I want to have
an another JOptionPane to confirm that sellection with three choices; YES,
NO, CANCEL

The code below explains this:

//after click a button

Object o = JOptionPane.showInputDialog(this, "There is a person with this
name in database \n Do you want to get this person details",
"Select Person",
JOptionPane.OK_CANCEL_OPTION, null, allPeople.toArray(), "Person");
if (o != null) {...
.....
}

It can be seen that here I used "JOptionPane.OK_CANCEL_OPTION" for the
confirmation. I tried to use other options such as
JOptionPane.YES_OPTION.... but I cannot find out a JOptionPane that provides
three choices Yes, No, Cancel as what I want (I can get only the option OK
and CANCEL). Is there a solution to overcome this.?

Many thanks
S.Hoa
 
A

Arnaud Berger

Hi,

Give a try to showConfirmDialog with JOptionPane.YES_NO_CANCEL_OPTION...

Regards,

Arnaud
 
A

Arnaud Berger

Hi,

showInputDialog doesn't have a version accepting an "optionype" int.
The JOptionPane.OK_CANCEL_OPTION (value 2 ) you pass doesn't affect at all
the buttons, because you pass this value to the "messagetype" parameter
expecting INFORMATION_MESSAGE
WARNING_MESSAGE <-- value 2 ...)
So in showInputDialog , you have no way to tell which buttons should appear.

By the way, what is the point in displaying a list of name when you already
know what person
you will want to display ?

So I'd rather go with showConfirmDialog, just displaying the name of the
user already existing with the same name.
The text would be ""The following person already has this name in database
\n Do you want to get this person details ? \n\n"+person.

Regards,

Arnaud
 
S

shoa

Thank you

The problem here is that there may be two or three people have the same name
in the database, not only one. That is why I have to use "showInputDialog".
The user then can select one of those people.

Regards
S.Hoa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,184
Latest member
ZNOChrista

Latest Threads

Top