public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType) { @Override public void selectInitialValue() { // This makes focusing more consistent between // various operating systems / window managers if(defaultFocusedComponent != null) { defaultFocusedComponent.requestFocusInWindow(); } } }; JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValueAsInteger(optionPane); }
public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent, Object[] options, Object defaultOption) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType, null, options, defaultOption) { @Override public void selectInitialValue() { // This makes focusing more consistent between // various operating systems / window managers if(defaultFocusedComponent != null) { defaultFocusedComponent.requestFocusInWindow(); } } }; JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValueAsInteger(optionPane); }
public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent, Object[] options, Object defaultOption) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType, null, options, defaultOption); JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValue(optionPane); }
public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType); JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValue(optionPane); }
public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType); JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValue(optionPane); }
public static int showConfirmDialog(Component parent, String title, JComponent content, int messageType, int optionType, final JComponent defaultFocusedComponent, Object[] options, Object defaultOption) { JOptionPane optionPane = new JOptionPane(content, messageType, optionType, null, options, defaultOption); JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setVisible(true); return getReturnValue(optionPane); }
public static int showValidatingConfirmDialog(Component parent, String title, JComponent component, int messageType, int optionType, final JComponent defaultFocusedComponent) { if (component instanceof VerifiedInputEditor) { final VerifyingOptionPane optionPane = new VerifyingOptionPane(component, messageType, optionType) { public void selectInitialValue() { // This is overridden so that the option pane dialog default // button doesn't get the focus. if (defaultFocusedComponent != null) { defaultFocusedComponent.requestFocusInWindow(); } } }; final InputVerificationStatusChangedListener verificationListener = optionPane::setOKEnabled; ((VerifiedInputEditor) component).addStatusChangedListener(verificationListener); final JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setModal(true); dlg.setVisible(true); return getReturnValueAsInteger(optionPane); } else { logger.warn("Component should implement VerifiedInputEditor for validating dialog to work. " + "Using normal dialog with no validating"); return showConfirmDialog(parent, title, component, messageType, optionType, null); } }
public static int showValidatingConfirmDialog(Component parent, String title, JComponent component, int messageType, int optionType, final JComponent defaultFocusedComponent) { if (component instanceof VerifiedInputEditor){ final VerifyingOptionPane optionPane = new VerifyingOptionPane(component, messageType, optionType) { /** * */ private static final long serialVersionUID = 7128847118051849761L; public void selectInitialValue() { // This is overridden so that the option pane dialog default // button doesn't get the focus. } }; final InputVerificationStatusChangedListener verificationListener = new InputVerificationStatusChangedListener() { public void verifiedStatusChanged(boolean verified) { optionPane.setOKEnabled(verified); } }; ((VerifiedInputEditor) component).addStatusChangedListener(verificationListener); final JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setModal(true); dlg.setVisible(true); return getReturnValue(optionPane); } else{ logger.warn("Component should implement VerifiedInputEditor for validating dialog to work. " + "Using normal dialog with no validating"); return showConfirmDialog(parent, title, component, messageType, optionType, null); } }
((VerifiedInputEditor) component).addStatusChangedListener(verificationListener); final JDialog dlg = createDialog(parent, title, optionPane, defaultFocusedComponent); dlg.setModal(true); dlg.setVisible(true);