Object[] selectionValues, Object initialSelectionValue) throws HeadlessException { JideOptionPane pane = new JideOptionPane(message, messageType, OK_CANCEL_OPTION, icon, null, null); pane.setLocale(parentComponent.getLocale()); pane.setWantsInput(true); pane.setSelectionValues(selectionValues); pane.setInitialSelectionValue(initialSelectionValue); pane.setComponentOrientation(((parentComponent == null) ? getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); JDialog dialog = pane.createDialog(parentComponent, title, style); pane.selectInitialValue(); dialog.setVisible(true); dialog.dispose(); Object value = pane.getInputValue();
/** * Creates and returns a new <code>JDialog</code> wrapping <code>this</code> centered on the * <code>parentComponent</code> in the <code>parentComponent</code>'s frame. <code>title</code> is the title of the * returned dialog. The returned <code>JDialog</code> will not be resizable by the user, however programs can invoke * <code>setResizable</code> on the <code>JDialog</code> instance to change this property. The returned * <code>JDialog</code> will be set up such that once it is closed, or the user clicks on one of the buttons, the * optionpane's value property will be set accordingly and the dialog will be closed. Each time the dialog is made * visible, it will reset the option pane's value property to <code>JOptionPane.UNINITIALIZED_VALUE</code> to ensure * the user's subsequent action closes the dialog properly. * * @param parentComponent determines the frame in which the dialog is displayed; if the <code>parentComponent</code> * has no <code>Frame</code>, a default <code>Frame</code> is used * @param title the title string for the dialog * * @return a new <code>JDialog</code> containing this instance * * @throws HeadlessException if <code>GraphicsEnvironment.isHeadless</code> returns <code>true</code> * @see java.awt.GraphicsEnvironment#isHeadless */ public JDialog createDialog(Component parentComponent, String title) throws HeadlessException { int style = styleFromMessageType(getMessageType()); return createDialog(parentComponent, title, style); }
msg += "\r\nCause: " + MiscUtils.getMessage(t.getCause()) + "."; JideOptionPane optionPane = new JideOptionPane(msg, JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION); optionPane.setTitle(title); optionPane.setOptions(new String[] {}); JButton reportButton = new JButton("Report Issue"); ((JComponent)optionPane.getComponent(optionPane.getComponentCount()-1)).add(reportButton); final JDialog dialog = optionPane.createDialog(getMainWindow(), "Error encountered"); dialog.setResizable(true); String details = t.getMessage() + "\r\n" + MiscUtils.getStackTrace(t); optionPane.setDetails(details); dialog.pack();
Icon icon, Object[] options, Object initialValue) throws HeadlessException { JideOptionPane pane = new JideOptionPane(message, messageType, optionType, icon, options, initialValue); pane.setLocale(parentComponent.getLocale()); pane.setInitialValue(initialValue); pane.setComponentOrientation(((parentComponent == null) ? getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); JDialog dialog = pane.createDialog(parentComponent, title, style); pane.selectInitialValue(); dialog.setVisible(true); dialog.dispose(); Object selectedValue = pane.getValue();
private static void displayPopup() { optionPane.setDetailsVisible(true); JDialog dialog = optionPane.createDialog(MapTool.getFrame(), I18N.getString("MapToolEventQueue.warning.title")); //$NON-NLS-1$ dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); }
@Override protected void dispatchEvent(AWTEvent event) { try { super.dispatchEvent(event); } catch (StackOverflowError soe) { log.error(soe, soe); optionPane.setTitle(I18N.getString("MapToolEventQueue.stackOverflow.title")); //$NON-NLS-1$ optionPane.setDetails(I18N.getString("MapToolEventQueue.stackOverflow")); displayPopup(); } catch (Throwable t) { log.error(t, t); optionPane.setTitle(I18N.getString("MapToolEventQueue.unexpectedError")); //$NON-NLS-1$ optionPane.setDetails(toString(t)); try { displayPopup(); } catch (Throwable thrown) { // Displaying the error message using the JideOptionPane has just failed. // Fallback to standard swing dialog. log.error(thrown, thrown); JOptionPane.showMessageDialog(null, toString(thrown), I18N.getString("MapToolEventQueue.unexpectedError"), JOptionPane.ERROR_MESSAGE); } } }
msg += "\r\nCause: " + ClientMiscUtils.getMessage(t.getCause()) + "."; JideOptionPane optionPane = new JideOptionPane(msg, JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION); optionPane.setTitle(title); optionPane.setOptions(new String[] {}); ((JComponent) optionPane.getComponent(optionPane.getComponentCount()-1)).add(cancelButton); ((JComponent) optionPane.getComponent(optionPane.getComponentCount()-1)).add(reportButton); final JDialog dialog = optionPane.createDialog(KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(), title); cancelButton.addActionListener(new ActionListener() { @Override optionPane.setDetails(details); dialog.pack();
JideOptionPane optionPane = new JideOptionPane(String.format("<html>Message: <i>%s</i><br><br>Click the <i>Details</i> button to see more information...<br><br>" + "Please report any issues you experience to the to the development team.</html>", MiscUtils.getMessage(x)), JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION); optionPane.setTitle("A problem was encountered while formatting."); optionPane.setOptions(new String[] {}); JButton reportButton = new JButton("Report Issue"); ((JComponent)optionPane.getComponent(optionPane.getComponentCount() - 1)).add(reportButton); final JDialog dialog = optionPane.createDialog(DialogUtils.getMainWindow(), "Format Unsuccessful"); dialog.setModal(true); dialog.setResizable(true); optionPane.setDetails(MiscUtils.getStackTrace(x));