Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JOptionPane needs help

Reply
Thread Tools

JOptionPane needs help

 
 
shoa
Guest
Posts: n/a
 
      05-13-2005
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



 
Reply With Quote
 
 
 
 
Arnaud Berger
Guest
Posts: n/a
 
      05-13-2005
Hi,

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

Regards,

Arnaud

"shoa" <(E-Mail Removed)> a écrit dans le message news:
1115952053.440531@ftpsrv1...
> 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:
>
> file://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
>
>
>



 
Reply With Quote
 
 
 
 
shoa
Guest
Posts: n/a
 
      05-13-2005
If I use showConfirmDialog, I cannot get the Object o

"Arnaud Berger" <(E-Mail Removed)> wrote in message
news:d61hgq$9co$(E-Mail Removed)...
> Hi,
>
> Give a try to showConfirmDialog with JOptionPane.YES_NO_CANCEL_OPTION...
>
> Regards,
>
> Arnaud
>
> "shoa" <(E-Mail Removed)> a écrit dans le message news:
> 1115952053.440531@ftpsrv1...
> > 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:
> >
> > file://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
> >
> >
> >

>
>



 
Reply With Quote
 
Arnaud Berger
Guest
Posts: n/a
 
      05-13-2005
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



"shoa" <(E-Mail Removed)> a écrit dans le message news:
1115978879.62092@ftpsrv1...
> If I use showConfirmDialog, I cannot get the Object o
>
> "Arnaud Berger" <(E-Mail Removed)> wrote in message
> news:d61hgq$9co$(E-Mail Removed)...
> > Hi,
> >
> > Give a try to showConfirmDialog with JOptionPane.YES_NO_CANCEL_OPTION...
> >
> > Regards,
> >
> > Arnaud
> >
> > "shoa" <(E-Mail Removed)> a écrit dans le message news:
> > 1115952053.440531@ftpsrv1...
> > > 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:
> > >
> > > file://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
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
shoa
Guest
Posts: n/a
 
      05-14-2005
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


"Arnaud Berger" <(E-Mail Removed)> wrote in message
news:d61vhc$m0l$(E-Mail Removed)...
> 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
>
>
>
> "shoa" <(E-Mail Removed)> a écrit dans le message news:
> 1115978879.62092@ftpsrv1...
> > If I use showConfirmDialog, I cannot get the Object o
> >
> > "Arnaud Berger" <(E-Mail Removed)> wrote in message
> > news:d61hgq$9co$(E-Mail Removed)...
> > > Hi,
> > >
> > > Give a try to showConfirmDialog with

JOptionPane.YES_NO_CANCEL_OPTION...
> > >
> > > Regards,
> > >
> > > Arnaud
> > >
> > > "shoa" <(E-Mail Removed)> a écrit dans le message news:
> > > 1115952053.440531@ftpsrv1...
> > > > 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:
> > > >
> > > > file://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
> > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JOptionPane need help HS1 Java 1 11-30-2004 10:57 PM
Using JOptionPane jazzy Java 0 04-18-2004 05:59 AM
thread safeness of JOptionPane et al Alex Hunsley Java 0 01-13-2004 11:52 AM
focus with multiple JOptionPane.showInputDialog calls Joseph M. DeAngelo Java 0 11-09-2003 07:48 AM
JOptionPane Cannot Override LookAndFeel's Font... SuperChuck Java 3 08-07-2003 03:33 PM



Advertisments