timer.setCoalesce(false); optPane.setMessage(message()); optPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); optPane.setOptionType(JOptionPane.DEFAULT_OPTION); optPane.addPropertyChangeListener(this);
public static void showPrettyMessageDialog(Component parent, Object message, String title, int type) { class PrettyOptionPane extends JOptionPane { PrettyOptionPane() { } @Override public int getMaxCharactersPerLineCount() { return maxCharactersPerLineCount; } } JOptionPane narrowPane = new PrettyOptionPane(); narrowPane.setMessage(message); narrowPane.setMessageType(type); JDialog errorDialog = narrowPane.createDialog(parent, title); errorDialog.setVisible(true); }
String htmlMsg = "<html>You can use</b>HTML here</html>"; JOptionPane dialogBox = new JOptionPane(); dialogBox.setMessage(msg); dialogBox.setMessageType(JOptionPane.INFORMATION_MESSAGE); //....
public AbstractValueEditor(final Class<V> type) { this.type = type; pane = new JOptionPane(); pane.setMessageType(JOptionPane.QUESTION_MESSAGE); pane.setOptionType(JOptionPane.OK_CANCEL_OPTION); }
JDialog dialog = null; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("Set Message"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3,1)); String[] buttonTxt = {"Need Help","Help Me","Counting"}; JButton[] buttons = new JButton[buttonTxt.length]; for (int i = 0; i < buttonTxt.length; i++) { buttons[i] = new JButton(buttonTxt[i]); panel.add(buttons[i]); } optionPane.setOptionType(JOptionPane.DEFAULT_OPTION); optionPane.add(panel); dialog = optionPane.createDialog(null, "Icon/Text Button"); dialog.setVisible(true);
JDialog dialog = null; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("Set Message"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3,1)); String[] buttonTxt = {"Need Help","Help Me","Counting"}; JButton[] buttons = new JButton[buttonTxt.length]; for (int i = 0; i < buttonTxt.length; i++) { buttons[i] = new JButton(buttonTxt[i]); panel.add(buttons[i]); } optionPane.setOptionType(JOptionPane.DEFAULT_OPTION); optionPane.add(panel,1); dialog = optionPane.createDialog(null, "Icon/Text Button"); dialog.setVisible(true);
public class JEnhancedOptionPane extends JOptionPane { public static String showInputDialog(final Object message, final Object[] options) throws HeadlessException { final JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE, OK_CANCEL_OPTION, null, options, null); pane.setWantsInput(true); pane.setComponentOrientation((getRootFrame()).getComponentOrientation()); pane.setMessageType(QUESTION_MESSAGE); pane.selectInitialValue(); final String title = UIManager.getString("OptionPane.inputDialogTitle", null); final JDialog dialog = pane.createDialog(null, title); dialog.setVisible(true); dialog.dispose(); final Object value = pane.getInputValue(); return (value == UNINITIALIZED_VALUE) ? null : (String) value; } }
private Object showInputDialog(String title, String message, String[] options) { JOptionPane pane = new JOptionPane(message + "\n\nPlease choose an action:"); pane.setMessageType(JOptionPane.QUESTION_MESSAGE); pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION); pane.setOptions(options); JDialog dialog = pane.createDialog(this, title); dialog.pack(); dialog.setVisible(true); return pane.getValue(); }
public class JEnhancedOptionPane extends JOptionPane { public static String showInputDialog(final Object message, final Object[] options) throws HeadlessException { final JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE, OK_CANCEL_OPTION, null, options, null); pane.setWantsInput(true); pane.setComponentOrientation((getRootFrame()).getComponentOrientation()); pane.setMessageType(QUESTION_MESSAGE); pane.selectInitialValue(); final String title = UIManager.getString("OptionPane.inputDialogTitle", null); final JDialog dialog = pane.createDialog(null, title); dialog.setVisible(true); dialog.dispose(); final Object value = pane.getInputValue(); return (value == UNINITIALIZED_VALUE) ? null : (String) value; } }
/** * Get the server-config.wsdd as a document to retrieve deployed services * * @return */ private Document getServerWSDD() { Document doc = null; try { String[] param = new String[]{"-u" + axisUser, "-w" + axisPass, "-l " + axisURL, "list"}; String ret = adminClient.process(param); doc = XMLUtils.newDocument( new ByteArrayInputStream(ret.getBytes())); } catch (Exception e) { JOptionPane pane = new JOptionPane(); String msg = e.toString(); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(msg); pane.setOptions(new String[]{"OK"}); JDialog dlg = pane.createDialog(null, "Login status"); dlg.setVisible(true); } return doc; }
private void showInfo() { String title = "Outlier information"; JLabel comp = new JLabel(); comp.setText(getInfo()); JOptionPane pane = new JOptionPane(comp); pane.setOptionType(JOptionPane.DEFAULT_OPTION); pane.setMessageType(JOptionPane.PLAIN_MESSAGE); PointerInfo pointerInfo = MouseInfo.getPointerInfo(); Point mousePoint = pointerInfo.getLocation(); JDialog dialog = pane.createDialog(this, title); dialog.setLocation(mousePoint); dialog.setVisible(true); }
/** * Get the server-config.wsdd as a document to retrieve deployed services * * @return */ private Document getServerWSDD() { Document doc = null; try { String[] param = new String[]{"-u" + axisUser, "-w" + axisPass, "-l " + axisURL, "list"}; String ret = adminClient.process(param); doc = XMLUtils.newDocument( new ByteArrayInputStream(ret.getBytes())); } catch (Exception e) { JOptionPane pane = new JOptionPane(); String msg = e.toString(); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(msg); pane.setOptions(new String[]{"OK"}); JDialog dlg = pane.createDialog(null, "Login status"); dlg.setVisible(true); } return doc; }
/** * Get the server-config.wsdd as a document to retrieve deployed services * * @return */ private Document getServerWSDD() { Document doc = null; try { String[] param = new String[]{"-u" + axisUser, "-w" + axisPass, "-l " + axisURL, "list"}; String ret = adminClient.process(param); doc = XMLUtils.newDocument( new ByteArrayInputStream(ret.getBytes())); } catch (Exception e) { JOptionPane pane = new JOptionPane(); String msg = e.toString(); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(msg); pane.setOptions(new String[]{"OK"}); JDialog dlg = pane.createDialog(null, "Login status"); dlg.setVisible(true); } return doc; }
JTextField field = getField(); optionPane.setMessage(new Object[]{"Type something: ", field}); optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE); optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog(parent, "My Customized OptionPane");
public class Main { public static List<Component> getAllComponents(final Container c) { Component[] comps = c.getComponents(); List<Component> compList = new ArrayList<Component>(); for (Component comp : comps) { compList.add(comp); if (comp instanceof Container) compList.addAll(getAllComponents((Container) comp)); } return compList; } public static void main(String[] args) { JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("What's your name?"); optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE); optionPane.setWantsInput(true); JDialog dialog = optionPane.createDialog("Simple Question"); for (Component c : getAllComponents(dialog)) { if (c instanceof JTextField) { c.setToolTipText("I'm a tooltip!"); } } dialog.setVisible(true); dialog.dispose(); } }
JOptionPane optPane = new JOptionPane(); optPane.setMessage(jsp); optPane.setMessageType(JOptionPane.PLAIN_MESSAGE); optPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); JFrame f = new OptionPanePanel();
comp.setMessageType(messageType);
JOptionPane pane = new JOptionPane(); String msg = e.toString(); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(msg); pane.setOptions(new String[]{"OK"});
private void cancelIndexing() { String message = ""; message += "WARNING: Canceling indexing before completion will result in an" + "\n"; message += "incomplete index. Rebuilding of the index will be REQUIRED." + "\n\n"; message += "Are you sure you want to continue?" + "\n "; JOptionPane jOptionPane = new JOptionPane(message); jOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE); String yes = "Yes"; String no = "No"; jOptionPane.setOptions(new String[] { yes, no }); Dialog d = jOptionPane.createDialog("WARNING"); jOptionPane.setInitialValue(no); d.setVisible(true); if (jOptionPane.getValue() != null && jOptionPane.getValue().equals(yes)) { this.cancelled = true; this.beginIndexingJButton.setEnabled(false); } }
this.optionPane.setMessageType(JOptionPane.PLAIN_MESSAGE); this.optionPane.setOptionType( disableCertificateSelection ?