/** * Brings up a sheet with a specified icon, where the initial choice is determined by the {@code * initialValue} parameter and the number of choices is determined by the {@code optionType} * parameter. * * <p>If {@code optionType} is {@code YES_NO_OPTION}, or {@code YES_NO_CANCEL_OPTION} and the * {@code options} parameter is {@code null}, then the options are supplied by the look and feel. * * <p>The {@code messageType} parameter is primarily used to supply a default icon from the look * and feel. * * @param parentComponent determines the {@code Frame} in which the dialog is displayed; if {@code * null}, or if the {@code parentComponent} has no {@code Frame}, the sheet is displayed as a * dialog. * @param message the {@code Object} to display * @param optionType an integer designating the options available on the dialog: {@code * YES_NO_OPTION}, or {@code YES_NO_CANCEL_OPTION} * @param messageType an integer designating the kind of message this is, primarily used to * determine the icon from the pluggable Look and Feel: {@code JOptionPane.ERROR_MESSAGE}, * {@code JOptionPane.INFORMATION_MESSAGE}, {@code JOptionPane.WARNING_MESSAGE}, {@code * JOptionPane.QUESTION_MESSAGE}, or {@code JOptionPane.PLAIN_MESSAGE} * @param icon the icon to display in the dialog * @param options an array of objects indicating the possible choices the user can make; if the * objects are components, they are rendered properly; non-{@code String} objects are rendered * using their {@code toString} methods; if this parameter is {@code null}, the options are * determined by the Look and Feel * @param initialValue the object that represents the default selection for the dialog; only * meaningful if {@code options} is used; can be {@code null} * @param listener The listener for SheetEvents. */ public static void showOptionSheet( Component parentComponent, Object message, int optionType, int messageType, Icon icon, Object[] options, Object initialValue, SheetListener listener) { JOptionPane pane = new JOptionPane(message, messageType, optionType, icon, options, initialValue); pane.setInitialValue(initialValue); pane.setComponentOrientation( ((parentComponent == null) ? JOptionPane.getRootFrame() : parentComponent) .getComponentOrientation()); int style = styleFromMessageType(messageType); JSheet sheet = createSheet(pane, parentComponent, style); pane.selectInitialValue(); sheet.addSheetListener(listener); sheet.show(); sheet.toFront(); }
public boolean run(String sDialogTitle, java.util.List<SortedRuleVO> excludeRules) throws RemoteException { this.pnlRules = new InsertRulePanel(); final SelectRuleTableModel tblmodel = new SelectRuleTableModel(); tblmodel.setExcludeRules(excludeRules); pnlRules.setModel(tblmodel); TableUtils.setPreferredColumnWidth(pnlRules.getTblRules(), 10, 10); final JOptionPane optionPane = new JOptionPane(pnlRules, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); optionPane.setInitialValue(null); pnlRules .getTblRules() .addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { optionPane.setValue(JOptionPane.OK_OPTION); } } }); final JDialog dlg = optionPane.createDialog( getParent(), getSpringLocaleDelegate().getMessage("InsertRuleController.1", "Regelauswahl")); dlg.setResizable(true); dlg.setVisible(true); boolean result = false; if (optionPane.getValue() != null) { final int iBtn = (Integer) optionPane.getValue(); result = (iBtn == JOptionPane.OK_OPTION); } return result; }