java - Recognize that user select Yes Or No in Joptionpane -


i have frame when user want delete record, warning pane should displayed.

but, have recognize if user select yes, remove selected row , if select no, don't remove it!

how?

if (e.getsource() == deleteuser) { joptionpane.showconfirmdialog(rootpane, "are sure delete?", "delete user", width);  // if yes, remove } 

from javadocs...

public static int showconfirmdialog(component parentcomponent,                     object message,                     string title,                     int optiontype)                              throws headlessexception  brings dialog number of choices determined optiontype parameter.  parameters:     parentcomponent - determines frame in dialog displayed; if null, or if parentcomponent has no frame, default frame used     message - object display     title - title string dialog     optiontype - int designating options available on dialog: yes_no_option, yes_no_cancel_option, or ok_cancel_option returns:     int indicating option selected user 

the return type dependent on value pass optiontype parameter

this suggest should like...

int result = joptionpane.showconfirmdialog(rootpane, "are sure delete?", "delete user", joptionpane.yes_no_option); if (result == joptionpane.yes_option) {     // here } 

have @ how make dialogs more details...


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -