List of utility methods to do JOptionPane Confirmation
boolean | confirmarEliminar(Component component, String titulo, String mensaje) confirmar Eliminar int botones = JOptionPane.CANCEL_OPTION; int respuesta = JOptionPane.showConfirmDialog(component, mensaje, titulo, botones, JOptionPane.QUESTION_MESSAGE); if (respuesta == JOptionPane.YES_OPTION) { return true; return false; |
boolean | confirmationBox(String msg, String title) confirmation Box int result = JOptionPane.showConfirmDialog(null, msg, title, JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { return true; } else { return false; |
boolean | confirmationPrompt(String msg, String title, Component parent) confirmation Prompt Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(parent, msg, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (n == 0) { return true; } else { return false; |
boolean | confirmChangeReference(boolean isChangingProject) confirm Change Reference int result = JOptionPane.showConfirmDialog(getFrontWindow(), "<HTML>Changing the " + (isChangingProject ? "project" : "reference") + " will remove current filters.<BR>Are you sure you want to do this?</HTML>", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); return result == JOptionPane.YES_OPTION; |
int | confirmDialog(Component owner, String title, String message) Use this instead of JOptionPane.showMessageDialog(..., JOptionPane.QUESTION_MESSAGE) Default ModalityType.DOCUMENT_MODAL return confirmDialog(owner, title, message, ModalityType.DOCUMENT_MODAL);
|
boolean | confirmDialog(String msg, String title) confirm Dialog return JOptionPane.showConfirmDialog(null, msg, title,
JOptionPane.YES_NO_OPTION) == JFileChooser.APPROVE_OPTION;
|
int | confirmDialogWorker(Component owner, String title, String message, ModalityType modalityType, int option) confirm Dialog Worker JOptionPane jop = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, option); JDialog dialog = jop.createDialog(owner, title); dialog.setModalityType(modalityType); dialog.setVisible(true); Object selectedValue = jop.getValue(); if (selectedValue == null) return JOptionPane.CLOSED_OPTION; if (selectedValue instanceof Integer) ... |
boolean | ConfirmMessage(String strMsg) Confirm Message if ((JOptionPane.showConfirmDialog((Component) null, strMsg, "Peticion", JOptionPane.OK_CANCEL_OPTION)) == JOptionPane.OK_OPTION) return true; else return false; |
int | confirmUserChoiceWithCustomOptions(final Component sourceComponent, final String question, final String defaultOption, final String... options) confirm User Choice With Custom Options final int selectedOption = JOptionPane.showOptionDialog(sourceComponent, question, "CONFIRM", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, defaultOption); return selectedOption; |
boolean | confirmWindow(String title, String message) confirm Window int result = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.OK_CANCEL_OPTION); return result != JOptionPane.CANCEL_OPTION; |