Пример #1
0
  // EDIT: in response to comment
  public static void showMessageDialog(Component parent, Object message, int timeout) {
    // run all of this on the EDT
    final JOptionPane optionPane = new JOptionPane(message);
    String title = UIManager.getString("OptionPane.messageDialogTitle");
    // int style = styleFromMessageType(JOptionPane.INFORMATION_MESSAGE);
    final JDialog dialog = optionPane.createDialog(parent, title);

    // timeout default is 5000 milliseconds
    Timer timer = new Timer(timeout, new AutoDismiss(dialog));
    timer.setRepeats(false);
    timer.start();
    if (dialog.isDisplayable()) dialog.setVisible(true);
  }