options[2] = useAnotherEncoding; fileFilterDialog.setOptions(options);
options[2] = cancel; fileFilterDialog.setOptions(options);
prefPane.setMessage(prefPanel); prefPane.setOptions(options); prefPane.setOpaque(true); this.setContentPane(prefPane);
progressMonitor = new ProgressMonitor(ProgressMonitorDemo.this, "Running a Long Task", "", 0, 100); progressMonitor.setMillisToDecideToPopup(0); progressMonitor.setMillisToPopup(0); progressMonitor.setProgress(0); JDialog dialog = (JDialog)progressMonitor.getAccessibleContext().getAccessibleParent(); JOptionPane pane = (JOptionPane)dialog.getContentPane().getComponent(0); pane.setOptions(new Object[]{});
public void show() { JOptionPane pane = new JOptionPane("Do you want to overwrite an existing file: " + file, JOptionPane.QUESTION_MESSAGE); pane.setOptions(OPTIONS); JDialog dialog = pane.createDialog(parent, "File exists"); dialog.setVisible(true); Object selectedValue = pane.getValue(); result = (selectedValue != null) ? selectedValue.toString() : CANCEL; }
JOptionPane optionPane = new JOptionPane(this,1,JOptionPane.PLAIN_MESSAGE); optionPane.setOptions(new Object[]{}); JDialog dialog = optionPane.createDialog(null, "Quick Help"); dialog.setLocation(1000,10); dialog.setAlwaysOnTop(dialog.isAlwaysOnTopSupported()); dialog.setVisible(true);
public void show() { JOptionPane pane = new JOptionPane( "One or more project files were deleted or renamed. " + "Do you want to save the changes or close the project?", JOptionPane.QUESTION_MESSAGE); pane.setOptions(OPTIONS); JDialog dialog = pane.createDialog(parent, "File deleted"); dialog.setVisible(true); Object selectedValue = pane.getValue(); // need to do an if..else chain, since // sometimes values are unexpected if (SAVE.equals(selectedValue)) { result = SAVE; } else if (CLOSE.equals(selectedValue)) { result = CLOSE; } else { result = CANCEL; } }
public void show() { JOptionPane pane = new JOptionPane( "You have unsaved changes. Do you want to save them?", JOptionPane.QUESTION_MESSAGE); pane.setOptions(new Object[] {SAVE_AND_CLOSE, CLOSE_WITHOUT_SAVE, CANCEL}); pane.setInitialValue(SAVE_AND_CLOSE); pane.createDialog(parent, "Unsaved Changes").setVisible(true); Object selectedValue = pane.getValue(); result = CANCEL; if (SAVE_AND_CLOSE.equals(selectedValue)) { result = SAVE_AND_CLOSE; } else if (CLOSE_WITHOUT_SAVE.equals(selectedValue)) { result = CLOSE_WITHOUT_SAVE; } }
@Override public void actionPerformed (ActionEvent arg0) { JOptionPane pane = new JOptionPane(I18N.getLocaleString("CONSOLE_CLIP_CONFIRM")); Object[] options = new String[] { I18N.getLocaleString("MAIN_YES"), I18N.getLocaleString("MAIN_CANCEL") }; pane.setOptions(options); JDialog dialog = pane.createDialog(new JFrame(), I18N.getLocaleString("CONSOLE_COPYCLIP")); dialog.setVisible(true); Object obj = pane.getValue(); int result = -1; for (int i = 0; i < options.length; i++) { if (options[i].equals(obj)) { result = i; } } if (result == 0) { StringSelection stringSelection = new StringSelection("FTB Launcher logs:\n" + Logger.getLogs() + "[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "]" + " Logs copied to clipboard"); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null); } } });
private static Object showDialog(final JComponent parent, final String title, final List<? extends IEditableProperty<?>> properties, final Object... buttonOptions) { final PropertiesUi panel = new PropertiesUi(properties, true); final JScrollPane scroll = new JScrollPane(panel); scroll.setBorder(null); scroll.getViewport().setBorder(null); final JOptionPane pane = new JOptionPane(scroll, JOptionPane.PLAIN_MESSAGE); pane.setOptions(buttonOptions); final JDialog window = pane.createDialog(JOptionPane.getFrameForComponent(parent), title); window.setVisible(true); return pane.getValue(); } }
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(); }
import javax.swing.*; import java.awt.*; public class CursorTest { public static void main(String[] args) { JLabel label = new JLabel("Move mouse here for hand cursor"); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JOptionPane pane = new JOptionPane(label); pane.setOptions(new Object[]{"OK"}); JFrame parent = new JFrame(); parent.setVisible(true); JDialog dialog = pane.createDialog(parent, "Test Dialog"); dialog.setModal(false); 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; }
private void showDialog(String name) { JCheckBox neverPromptAgainBox = new JCheckBox("Always delete without prompt."); Object message[] = { String.format("Are you sure you would like to delete the %s?", name), neverPromptAgainBox }; JOptionPane pane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE); pane.setOptions(new Object[]{ DELETE, "Cancel" }); pane.setInitialValue(DELETE); pane.createDialog(Application.getFrame(), "Confirm Delete").setVisible(true); shouldDelete = DELETE.equals(pane.getValue()); // If the user clicks "cancel" or window close button, we'll just ignore whatever's in the checkbox because // it's non-sensical. if (shouldDelete) { Preferences pref = Application.getInstance().getPreferencesNode( GeneralPreferences.class, ""); pref.putBoolean( GeneralPreferences.DELETE_PROMPT_PREFERENCE, neverPromptAgainBox.isSelected()); } }
public void start() { PrintPanel printPanel = new PrintPanel(this.graph); JOptionPane optionPane = new JOptionPane(); optionPane.setOptions(new String[] { this.printCloseText }); optionPane.setMessage(printPanel); optionPane.setBorder(new EmptyBorder(0, 0, 10, 0)); this.dialogFactory.showDialog(optionPane, this.printTitle, 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; }
private static String showOverwriteWarningDialog(File outputFile) { JOptionPane pane = new JOptionPane( format("File %s already exists. Overwrite?", outputFile), WARNING_MESSAGE); pane.setOptions(new String[]{OVERWRITE_YES, OVERWRITE_YES_ALL, OVERWRITE_NO, OVERWRITE_CANCEL}); pane.setInitialValue(OVERWRITE_NO); JDialog dialog = pane.createDialog(PixelitorWindow.getInstance(), "Warning"); dialog.setVisible(true); String value = (String) pane.getValue(); String answer; if (value == null) { // cancelled answer = OVERWRITE_CANCEL; } else { answer = value; } return answer; } }
@Override public void actionPerformed (ActionEvent arg0) { JOptionPane pane = new JOptionPane("The log will be sent to the FTB paste site and opened in your browser"); Object[] options = new String[] { "Yes do it", "Cancel" }; pane.setOptions(options); JDialog dialog = pane.createDialog(new JFrame(), I18N.getLocaleString("CONSOLE_PASTE")); dialog.setVisible(true); Object obj = pane.getValue(); int result = -1; for (int i = 0; i < options.length; i++) { if (options[i].equals(obj)) { result = i; } } if (result == 0) { PastebinPoster thread = new PastebinPoster(); thread.start(); } } });
final JOptionPane optionPane = new JOptionPane("What is your first name?", JOptionPane.QUESTION_MESSAGE); optionPane.setWantsInput(true); Action accept = new AbstractAction("OK") { private static final long serialVersionUID = 1; public void actionPerformed(ActionEvent event) { Object value = optionPane.getInputValue(); if (value != null && !value.toString().isEmpty()) { // This dismisses the JOptionPane dialog. optionPane.setValue(JOptionPane.OK_OPTION); } } }; Object acceptButton = new JButton(accept); optionPane.setOptions(new Object[] { acceptButton, "Cancel" }); optionPane.setInitialValue(acceptButton); // Waits until dialog is dismissed. optionPane.createDialog(null, "First Name").setVisible(true); if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(optionPane.getValue())) { // User canceled dialog. return; } String fn = optionPane.getInputValue().toString();
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); } }