javax.swing.JOptionPane.setInitialValue()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中javax.swing.JOptionPane.setInitialValue()方法的一些代码示例,展示了JOptionPane.setInitialValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JOptionPane.setInitialValue()方法的具体详情如下:
包路径:javax.swing.JOptionPane
类名称:JOptionPane
方法名:setInitialValue

JOptionPane.setInitialValue介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: libgdx/libgdx

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: libgdx/libgdx

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: libgdx/libgdx

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

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;
  }
}

代码示例来源:origin: stackoverflow.com

public static int showOptionDialog(Component parentComponent,
   Object message, String title, int optionType, int messageType,
   Icon icon, Object[] options, Object initialValue) 
   throws HeadlessException {
   JOptionPane             pane = new JOptionPane(message, messageType,
                           optionType, icon,
                           options, initialValue);
   pane.setInitialValue(initialValue);
   pane.setComponentOrientation(((parentComponent == null) ?
   getRootFrame() : parentComponent).getComponentOrientation());
   int style = styleFromMessageType(messageType);
   JDialog dialog = pane.createDialog(parentComponent, title, style);
   pane.selectInitialValue();
   dialog.show();    
   //..Result handling code
 }

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

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());
  }
}

代码示例来源:origin: lbalazscs/Pixelitor

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;
  }
}

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl

null);
pane.setInitialValue(null);
pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation());

代码示例来源:origin: org.rescarta.rc-indexer/rc-indexer

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);
  }
}

代码示例来源:origin: nroduit/Weasis

pane.setInitialValue(createBtn);
} else {
  pane.setOptions(new JButton[] { deleteBtn, copyBtn });
  pane.setInitialValue(copyBtn);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

Object[] options = {labels.getString("application.exit.saveOption"), labels.getString("application.exit.cancelOption"), labels.getString("application.exit.dontSaveOption")};
pane.setOptions(options);
pane.setInitialValue(options[0]);
pane.putClientProperty("Quaqua.OptionPane.destructiveOption", 2);
JSheet.showSheet(pane, unsavedView.getComponent(), new SheetListener() {
Object[] options = {labels.getString("application.exit.reviewChangesOption"), labels.getString("application.exit.cancelOption"), labels.getString("application.exit.discardChangesOption")};
pane.setOptions(options);
pane.setInitialValue(options[0]);
pane.putClientProperty(
    "Quaqua.OptionPane.destructiveOption", 2);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

Object[] options = {labels.getString("application.exit.saveOption"), labels.getString("application.exit.cancelOption"), labels.getString("application.exit.dontSaveOption")};
pane.setOptions(options);
pane.setInitialValue(options[0]);
pane.putClientProperty("Quaqua.OptionPane.destructiveOption", 2);
JSheet.showSheet(pane, unsavedView.getComponent(), new SheetListener() {

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

options, initialValue);
pane.setInitialValue(initialValue);
pane.setComponentOrientation(((parentComponent == null) ? JOptionPane.getRootFrame() : parentComponent).getComponentOrientation());

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

};
pane.setOptions(options);
pane.setInitialValue(options[0]);
pane.putClientProperty("Quaqua.OptionPane.destructiveOption", 2);
JSheet.showSheet(pane, v.getComponent(), new SheetListener() {

相关文章