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

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

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

JOptionPane.setMessageType介绍

暂无

代码示例

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

timer.setCoalesce(false);
optPane.setMessage(message());
optPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
optPane.setOptionType(JOptionPane.DEFAULT_OPTION);
optPane.addPropertyChangeListener(this);

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

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

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

String htmlMsg = "<html>You can use</b>HTML here</html>";

JOptionPane dialogBox = new JOptionPane();
dialogBox.setMessage(msg);
dialogBox.setMessageType(JOptionPane.INFORMATION_MESSAGE);
//....

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

public AbstractValueEditor(final Class<V> type) {
  this.type = type;
  
  pane = new JOptionPane();
  pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
  pane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
}

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

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

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

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

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

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

代码示例来源:origin: pavelfatin/typometer

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

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

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

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

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

代码示例来源:origin: nz.ac.waikato.cms.moa/moa

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

代码示例来源:origin: org.apache.axis/axis

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

代码示例来源:origin: org.apache.axis/com.springsource.org.apache.axis

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

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

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

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

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

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

JOptionPane optPane = new JOptionPane();
optPane.setMessage(jsp);
optPane.setMessageType(JOptionPane.PLAIN_MESSAGE);
optPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
JFrame f = new OptionPanePanel();

代码示例来源:origin: org.xworker/xworker_core

comp.setMessageType(messageType);

代码示例来源:origin: org.apache.axis/com.springsource.org.apache.axis

JOptionPane pane = new JOptionPane();
String msg = e.toString();
pane.setMessageType(JOptionPane.WARNING_MESSAGE);
pane.setMessage(msg);
pane.setOptions(new String[]{"OK"});

代码示例来源: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: es.gob.afirma/afirma-ui-core-jse-keystores

this.optionPane.setMessageType(JOptionPane.PLAIN_MESSAGE);
this.optionPane.setOptionType(
  disableCertificateSelection ?

相关文章