MCPcopy Index your code
hub / github.com/processing/processing / showCustomQuestion

Method showCustomQuestion

app/src/processing/app/Messages.java:287–323  ·  view source on GitHub ↗

@param highlight A valid array index for options[] that specifies the default (i.e. safe) choice. @return The (zero-based) index of the selected value, -1 otherwise.

(Frame editor, String title,
                                       String primary, String secondary,
                                       int highlight, String... options)

Source from the content-addressed store, hash-verified

285 * @return The (zero-based) index of the selected value, -1 otherwise.
286 */
287 static public int showCustomQuestion(Frame editor, String title,
288 String primary, String secondary,
289 int highlight, String... options) {
290 Object result;
291 if (!Platform.isMacOS()) {
292 return JOptionPane.showOptionDialog(editor,
293 "<html><body><b>" + primary + "</b><br>" + secondary, title,
294 JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null,
295 options, options[highlight]);
296 } else {
297 // Pane formatting adapted from the Quaqua guide
298 // http://www.randelshofer.ch/quaqua/guide/joptionpane.html
299 JOptionPane pane =
300 new JOptionPane("<html> " +
301 "<head> <style type=\"text/css\">"+
302 "b { font: 13pt \"Lucida Grande\" }"+
303 "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }"+
304 "</style> </head>" +
305 "<b>" + primary + "</b>" +
306 "<p>" + secondary, // + "</p>",
307 JOptionPane.QUESTION_MESSAGE);
308
309 pane.setOptions(options);
310
311 // highlight the safest option ala apple hig
312 pane.setInitialValue(options[highlight]);
313
314 JDialog dialog = pane.createDialog(editor, null);
315 dialog.setVisible(true);
316
317 result = pane.getValue();
318 }
319 for (int i = 0; i < options.length; i++) {
320 if (result != null && result.equals(options[i])) return i;
321 }
322 return -1;
323 }
324
325
326 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 2

showYesNoQuestionMethod · 0.95
showReloadPromptMethod · 0.95

Calls 4

isMacOSMethod · 0.95
getValueMethod · 0.80
setVisibleMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected