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

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

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

JOptionPane.<init>介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

encodingPanel.add(textPanel);
encodingPanel.add(Box.createVerticalStrut(5));
final JOptionPane fileFilterDialog = new JOptionPane();
fileFilterDialog.setMessage(encodingPanel);
JButton[] options = new JButton[3];
final JDialog dialog = fileFilterDialog.createDialog(null, "Default encoding changed...");
useNewEncoding.addActionListener(arg0 -> {
 FileTreeModel.setCurEncoding(encoding);
  System.out.println("encoding null!!");
 setEncoding.setText(encoding);
 dialog.setVisible(false);
});
useOldEncoding.addActionListener(e -> dialog.setVisible(false));
useAnotherEncoding.addActionListener(e -> {
 dialog.setVisible(false);
 alternateEncodingPrompt(encoding);
});

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

private void showProgressPanel(List<ComponentDescription> comps, boolean install) {
  final ProgressPanel pp = new ProgressPanel(comps, install);
  final JOptionPane optionPane = new JOptionPane(pp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
      new String[] { "Abort" }, "Abort");
  // optionPane.setPreferredSize(new Dimension(640,480));
  final JDialog dialog = new JDialog((Frame) null, "Progress", false);
  dialog.setContentPane(optionPane);
  optionPane.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      String prop = e.getPropertyName();
      if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
        pp.requestExit();
        dialog.setVisible(false);
      }
    }
  });
  dialog.pack();
  dialog.setVisible(true);
  new Thread(pp).start();
}

代码示例来源:origin: net.imagej/ij-ui-swing

public SwingDialogPrompt(final String message, final String title,
  final MessageType messageType, final OptionType optionType)
{
  pane =
    new JOptionPane(message, msgMap.get(messageType), optionMap
      .get(optionType));
  // pane.set.Xxxx(...); // Configure
  dialog = pane.createDialog(null, title);
}

代码示例来源:origin: stanfordnlp/CoreNLP

final JOptionPane fileFilterDialog = new JOptionPane();
fileFilterDialog.setMessage(fileFilterPanel);
JButton[] options = new JButton[3];
final JDialog dialog = fileFilterDialog.createDialog(null, "Set file filters...");
okay.addActionListener(arg0 -> {
 dialog.setVisible(false);
 startFileLoadingThread(filters, cFiles);
});
 dialog.pack();
});
cancel.addActionListener(e -> dialog.setVisible(false));
dialog.getRootPane().setDefaultButton(okay);
dialog.pack();
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);

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

private void showProgressPanel(List<ComponentDescription> comps, boolean install) {
  final ProgressPanel pp = new ProgressPanel(comps, install);
  final JOptionPane optionPane = new JOptionPane(pp, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
      new String[] { "Abort" }, "Abort");
  // optionPane.setPreferredSize(new Dimension(640,480));
  final JDialog dialog = new JDialog((Frame) null, "Progress", false);
  dialog.setContentPane(optionPane);
  optionPane.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      String prop = e.getPropertyName();
      if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
        pp.requestExit();
        dialog.setVisible(false);
      }
    }
  });
  dialog.pack();
  dialog.setVisible(true);
  new Thread(pp).start();
}

代码示例来源:origin: org.scijava/scijava-ui-swing

public SwingDialogPrompt(final String message, final String title,
  final MessageType messageType, final OptionType optionType)
{
  pane =
    new JOptionPane(message, msgMap.get(messageType), optionMap
      .get(optionType));
  // pane.set.Xxxx(...); // Configure
  dialog = pane.createDialog(null, title);
  // dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}

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

JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null,
  null);
placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField)));
JDialog dialog = pane.createDialog(null, title);
pane.selectInitialValue();
dialog.setVisible(true);
dialog.dispose();

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

private void miProxy1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_miProxy1ActionPerformed
  ProxyPanel prp = new ProxyPanel(System.getProperty("http.proxyHost"), System.getProperty("http.proxyPort"));
  final JOptionPane optionPane = new JOptionPane(prp, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION, null,
      new String[] { "OK", "Cancel" }, "OK");
  final JDialog dialog = new JDialog((Frame) null, "", true);
  dialog.setContentPane(optionPane);
  optionPane.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      String prop = e.getPropertyName();
      if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
        dialog.setVisible(false);
      }
    }
  });
  dialog.pack();
  dialog.setVisible(true);
  if ("OK".equals(optionPane.getValue())) {
    System.setProperty("http.proxyHost", prp.getProxyHost());
    System.setProperty("http.proxyPort", prp.getProxyPort());
  }
}// GEN-LAST:event_miProxy1ActionPerformed

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

import javax.swing.JDialog;
import javax.swing.JOptionPane;
public class TheComboBoxes {
  public static void main(String[] args) {
    JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n"
        + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE,
        JOptionPane.YES_NO_OPTION);
    JDialog dialog = optionPane.createDialog("click");
    dialog.setVisible(true);
  }
}

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

JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null,
  null);
placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField)));
JDialog dialog = pane.createDialog(null, title);
pane.selectInitialValue();
dialog.setVisible(true);
dialog.dispose();

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

private void miProxy1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_miProxy1ActionPerformed
  ProxyPanel prp = new ProxyPanel(System.getProperty("http.proxyHost"), System.getProperty("http.proxyPort"));
  final JOptionPane optionPane = new JOptionPane(prp, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION, null,
      new String[] { "OK", "Cancel" }, "OK");
  final JDialog dialog = new JDialog((Frame) null, "", true);
  dialog.setContentPane(optionPane);
  optionPane.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      String prop = e.getPropertyName();
      if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
        dialog.setVisible(false);
      }
    }
  });
  dialog.pack();
  dialog.setVisible(true);
  if ("OK".equals(optionPane.getValue())) {
    System.setProperty("http.proxyHost", prp.getProxyHost());
    System.setProperty("http.proxyPort", prp.getProxyPort());
  }
}// GEN-LAST:event_miProxy1ActionPerformed

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

JOptionPane pane = new JOptionPane("pane");
JDialog dialog = pane.createDialog(null, "Title");
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
dialog.show();

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

JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null,
  null);
placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField)));
JDialog dialog = pane.createDialog(null, title);
pane.selectInitialValue();
dialog.setVisible(true);
dialog.dispose();

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

@Override
  protected PasswordAuthentication getPasswordAuthentication() {
    PasswordPanel passP = new PasswordPanel();
    final JOptionPane optionPane = new JOptionPane(passP, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION,
        null, new String[] { "OK", "Cancel" }, "OK");
    final JDialog dialog = new JDialog((Frame) null, "", true);
    dialog.setContentPane(optionPane);
    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
        String prop = e.getPropertyName();
        if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
          dialog.setVisible(false);
        }
      }
    });
    dialog.pack();
    dialog.setVisible(true);
    if ("OK".equals(optionPane.getValue())) {
      return new PasswordAuthentication(passP.getUser(), passP.getPassword());
    }
    return null;
  }
});

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

JOptionPane pane = new JOptionPane("message");
JDialog dialog = pane.createDialog(null, "Title");
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
dialog.show();

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

JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null,
  null);
placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField)));
JDialog dialog = pane.createDialog(null, title);
pane.selectInitialValue();
dialog.setVisible(true);
dialog.dispose();

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

System.out.println("Showing license " + licenseURL + " for " + comps.size() + " components");
LicensePanel licensePanel = new LicensePanel(localURL, comps);
final JOptionPane optionPane = new JOptionPane(licensePanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION,
    null, new String[] { "Reject", "Accept" }, "Reject");
optionPane.setPreferredSize(new Dimension(800, 600));
dialog.setVisible(true);

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

public static String getPassword(String title) {
    JPanel panel = new JPanel();
    final JPasswordField passwordField = new JPasswordField(10);
    panel.add(new JLabel("Password"));
    panel.add(passwordField);
    JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
      @Override
      public void selectInitialValue() {
        passwordField.requestFocusInWindow();
      }
    };
    pane.createDialog(null, title).setVisible(true);
    return passwordField.getPassword().length == 0 ? null : new String(passwordField.getPassword());
}

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

JOptionPane optionPane = new JOptionPane();
JDialog dialog = optionPane.createDialog("Title");
dialog.setAlwaysOnTop(alwaysOnTop);
dialog.setVisible(true);

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

System.out.println("Showing license " + licenseURL + " for " + comps.size() + " components");
LicensePanel licensePanel = new LicensePanel(localURL, comps);
final JOptionPane optionPane = new JOptionPane(licensePanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION,
    null, new String[] { "Reject", "Accept" }, "Reject");
optionPane.setPreferredSize(new Dimension(800, 600));
dialog.setVisible(true);

相关文章