JOptionPane needs help

Discussion in 'Java' started by shoa, May 13, 2005.

  1. shoa

    shoa Guest

    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
    shoa, May 13, 2005
    #1
    1. Advertising

  2. Hi,

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

    Regards,

    Arnaud

    "shoa" <> 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
    >
    >
    >
    Arnaud Berger, May 13, 2005
    #2
    1. Advertising

  3. shoa

    shoa Guest

    If I use showConfirmDialog, I cannot get the Object o

    "Arnaud Berger" <> wrote in message
    news:d61hgq$9co$...
    > Hi,
    >
    > Give a try to showConfirmDialog with JOptionPane.YES_NO_CANCEL_OPTION...
    >
    > Regards,
    >
    > Arnaud
    >
    > "shoa" <> 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
    > >
    > >
    > >

    >
    >
    shoa, May 13, 2005
    #3
  4. 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" <> a écrit dans le message news:
    1115978879.62092@ftpsrv1...
    > If I use showConfirmDialog, I cannot get the Object o
    >
    > "Arnaud Berger" <> wrote in message
    > news:d61hgq$9co$...
    > > Hi,
    > >
    > > Give a try to showConfirmDialog with JOptionPane.YES_NO_CANCEL_OPTION...
    > >
    > > Regards,
    > >
    > > Arnaud
    > >
    > > "shoa" <> 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
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Arnaud Berger, May 13, 2005
    #4
  5. shoa

    shoa Guest

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

    JOptionPane.YES_NO_CANCEL_OPTION...
    > > >
    > > > Regards,
    > > >
    > > > Arnaud
    > > >
    > > > "shoa" <> 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
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    shoa, May 14, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SuperChuck
    Replies:
    3
    Views:
    4,075
    Sandip Chitale
    Aug 7, 2003
  2. Joseph M. DeAngelo
    Replies:
    0
    Views:
    1,090
    Joseph M. DeAngelo
    Nov 9, 2003
  3. Alex Hunsley

    thread safeness of JOptionPane et al

    Alex Hunsley, Jan 13, 2004, in forum: Java
    Replies:
    0
    Views:
    766
    Alex Hunsley
    Jan 13, 2004
  4. jazzy

    Using JOptionPane

    jazzy, Apr 18, 2004, in forum: Java
    Replies:
    0
    Views:
    366
    jazzy
    Apr 18, 2004
  5. HS1

    JOptionPane need help

    HS1, Nov 30, 2004, in forum: Java
    Replies:
    1
    Views:
    363
    Sudsy
    Nov 30, 2004
Loading...

Share This Page