Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showMessageDialog.

Prototype

public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType)
        throws HeadlessException 

Source Link

Document

Brings up a dialog that displays a message using a default icon determined by the messageType parameter.

Usage

From source file:com.clank.launcher.swing.SwingHelper.java

public static void browseDir(File file, Component component) {
    try {/*from   w  w  w.  java 2  s. com*/
        Desktop.getDesktop().open(file);
    } catch (IOException e) {
        JOptionPane.showMessageDialog(component, _("errors.openDirError", file.getAbsolutePath()),
                _("errorTitle"), JOptionPane.ERROR_MESSAGE);
    }
}

From source file:EditorPaneExample1.java

public EditorPaneExample1() {
    super("JEditorPane Example 1");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(4, 4));
    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, "West");
    textField = new JTextField(32);
    panel.add(textField, "Center");

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();
            try {
                // Try to display the page
                pane.setPage(url);//www  . j a v a  2s.  c  o m
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
}

From source file:com.a544jh.kanamemory.ui.ProfileChooserPanel.java

public void populateList() {
    listmodel = new DefaultListModel<>();
    ArrayList<String> names;
    try {// w  ww  .j  a v a  2 s  . co m
        names = JsonFileReader.ProfilesList("profiles");
    } catch (FileNotFoundException ex) {
        System.out.println("Profiles file not found. A new one will be created.");
        names = new ArrayList<>();
    } catch (JSONException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage() + "\nFix or delete the profiles file.",
                "Profiles file malformed", JOptionPane.ERROR_MESSAGE);
        System.exit(0);
        names = new ArrayList<>();
    }
    for (String string : names) {
        listmodel.addElement(string);
    }
    profilesList.setModel(listmodel);
}

From source file:org.argouml.application.Main.java

/**
 * The main entry point of ArgoUML./*  ww  w  .  jav a2  s .c  o m*/
 * @param args command line parameters
 */
public static void main(String[] args) {
    try {
        LOG.info("ArgoUML Started.");

        SimpleTimer st = new SimpleTimer();
        st.mark("begin");

        initPreinitialize();

        st.mark("arguments");
        parseCommandLine(args);

        // Register our last chance exception handler
        AwtExceptionHandler.registerExceptionHandler();

        // Get the splash screen up as early as possible
        st.mark("create splash");
        SplashScreen splash = null;
        if (!batch) {
            // We have to do this to set the LAF for the splash screen
            st.mark("initialize laf");
            LookAndFeelMgr.getInstance().initializeLookAndFeel();
            if (theTheme != null) {
                LookAndFeelMgr.getInstance().setCurrentTheme(theTheme);
            }
            if (doSplash) {
                splash = initializeSplash();
            }
        }

        // main initialization happens here
        ProjectBrowser pb = initializeSubsystems(st, splash);

        // Needs to happen after initialization is done & modules loaded
        st.mark("perform commands");
        if (batch) {
            // TODO: Add an "open most recent project" command so that 
            // command state can be decoupled from user settings?
            performCommandsInternal(commands);
            commands = null;

            System.out.println("Exiting because we are running in batch.");
            new ActionExit().doCommand(null);
            return;
        }

        if (reloadRecent && projectName == null) {
            projectName = getMostRecentProject();
        }

        URL urlToOpen = null;
        if (projectName != null) {
            projectName = PersistenceManager.getInstance().fixExtension(projectName);
            urlToOpen = projectUrl(projectName, urlToOpen);
        }

        openProject(st, splash, pb, urlToOpen);

        st.mark("perspectives");
        if (splash != null) {
            splash.updateProgress(75);
        }

        st.mark("open window");
        updateProgress(splash, 95, "statusmsg.bar.open-project-browser");
        ArgoFrame.getFrame().setVisible(true);

        st.mark("close splash");
        if (splash != null) {
            splash.setVisible(false);
            splash.dispose();
            splash = null;
        }

        // Aufrufen der Aufgabenstellung
        if (taskID != null) {
            ActionShowTask task = new ActionShowTask();
            task.showTask();
            if (projectName == null && ActionShowTask.taskDescription != null
                    && (ActionShowTask.taskDescription.toLowerCase().contains("aktivittsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivitts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivit&auml;tsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivit&auml;ts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity diagram")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity-diagram"))) {
                new ActionActivityDiagram().actionPerformed(null);
            }
        }

        performCommands(commands);
        commands = null;

        st.mark("start critics");
        Runnable startCritics = new StartCritics();
        Main.addPostLoadAction(startCritics);

        st.mark("start loading modules");
        Runnable moduleLoader = new LoadModules();
        Main.addPostLoadAction(moduleLoader);

        PostLoad pl = new PostLoad(postLoadActions);
        Thread postLoadThead = new Thread(pl);
        postLoadThead.start();

        LOG.info("");
        LOG.info("profile of load time ############");
        for (Enumeration i = st.result(); i.hasMoreElements();) {
            LOG.info(i.nextElement());
        }
        LOG.info("#################################");
        LOG.info("");

        st = null;
        ArgoFrame.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        // Andreas: just temporary: a warning dialog for uml2...
        if (showUml2warning && Model.getFacade().getUmlVersion().startsWith("2")) {
            JOptionPane.showMessageDialog(ArgoFrame.getFrame(),
                    "You are running an experimental version not meant for productive work!",
                    "UML2 pre-alpha warning", JOptionPane.WARNING_MESSAGE);
        }

        //ToolTipManager.sharedInstance().setInitialDelay(500);
        ToolTipManager.sharedInstance().setDismissDelay(50000000);
    } catch (Throwable t) {
        try {
            LOG.fatal("Fatal error on startup.  ArgoUML failed to start", t);
        } finally {
            System.out.println("Fatal error on startup.  " + "ArgoUML failed to start.");
            t.printStackTrace();
            System.exit(1);
        }
    }
}

From source file:de.weltraumschaf.minesweeper.control.VersionInfoListener.java

@Override
public void actionPerformed(final ActionEvent e) {
    JOptionPane.showMessageDialog(main, String.format("Version: %s", version.toString()), main.getTitle(),
            JOptionPane.PLAIN_MESSAGE);
}

From source file:heimerdinger.HeimerdingerFrame.java

/**
 * Creates new form HeimerdingerFrame/*from ww  w .j a va 2s  .  c  om*/
 */
public HeimerdingerFrame() {
    initComponents();

    if (!connectDB()) {
        JOptionPane.showMessageDialog(null, "Could not connect to database. Check LOG for more infomation.",
                "ERROR", JOptionPane.ERROR_MESSAGE);
        System.exit(0);
    }

    this.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (this.getWidth() / 2),
            (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (this.getHeight() / 2));

    initLastSession();
}

From source file:net.sf.firemox.tools.MSaveDeck.java

/**
 * Saves deck to ASCII file from specified staticTurnLists. This new file will
 * contain the card names sorted in alphabetical order with their quantity
 * with this format :<br>/*from  ww  w.  ja  va 2 s .  c om*/
 * <i>card's name </i> <b>; </b> <i>qty </i> <b>\n </b> <br>
 * 
 * @param fileName
 *          Name of new file.
 * @param names
 *          ListModel of card names.
 * @param parent
 *          the parent
 * @return true if the current deck has been correctly saved. false otherwise.
 */
public static boolean saveDeck(String fileName, MListModel<MCardCompare> names, JFrame parent) {
    PrintWriter outStream = null;
    try {
        // create the deckfile. If it was already existing, it would be scrathed.
        outStream = new PrintWriter(new FileOutputStream(fileName));
    } catch (FileNotFoundException ex) {
        JOptionPane.showMessageDialog(parent,
                "Cannot create/modify the specified deck file:" + fileName + "\n" + ex.getMessage(),
                "File creation problem", JOptionPane.ERROR_MESSAGE);
        return false;
    }

    Object[] namesArray = names.toArray();
    MCardCompare[] cards = new MCardCompare[namesArray.length];
    System.arraycopy(namesArray, 0, cards, 0, namesArray.length);

    // sorts names
    Arrays.sort(cards, new MCardCompare());
    // writes lines corresponding to this format : "card;quantity\n"
    for (int i = 0; i < cards.length; i++) {
        outStream.println(cards[i].toString());
    }
    IOUtils.closeQuietly(outStream);

    // successfull deck save
    JOptionPane.showMessageDialog(parent,
            "Saving file " + fileName.substring(fileName.lastIndexOf("/") + 1) + " was successfully completed.",
            "Save success", JOptionPane.INFORMATION_MESSAGE);
    return true;
}

From source file:dbseer.gui.actions.OpenDirectoryAction.java

@Override
public void actionPerformed(ActionEvent actionEvent) {
    if (profile.getLive()) {
        JOptionPane.showMessageDialog(null, "You cannot import a directory for the live dataset.", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;//from  ww w. ja v a 2 s  .  co  m
    }
    //DBSeerConfiguration config = DBSeerGUI.config;
    loadDialog.createFileDialog("Import from Directory", DBSeerFileLoadDialog.DIRECTORY_ONLY);
    loadDialog.showDialog();

    if (loadDialog.getFile() != null) {
        profile.setPath(loadDialog.getFile().getAbsolutePath());
        profile.loadDataset(true);
    }

    // old implementation
    //      if (loadDialog.getFile() != null)
    //      {
    //         profile.clearTransactionTypes();
    //         String[] files = loadDialog.getFile().list();
    //         String directory = loadDialog.getFile().getAbsolutePath();
    //         if (files != null)
    //         {
    //            for (String file : files)
    //            {
    //               String fileLower = file.toLowerCase();
    //
    //               file = directory + "/" + file;
    //               if (fileLower.contains("mon"))
    //               {
    //                  profile.setMonitoringDataPath(file);
    //               }
    //               else if (fileLower.contains("alllogs-t"))
    //               {
    //                  profile.setTransactionFilePath(file);
    //               }
    //               else if (fileLower.contains("alllogs-q"))
    //               {
    //                  profile.setQueryFilePath(file);
    //               }
    //               else if (fileLower.contains("alllogs-s"))
    //               {
    //                  profile.setStatementFilePath(file);
    //               }
    //               else if (fileLower.contains("header"))
    //               {
    //                  profile.setHeaderPath(file);
    //               }
    //               else if (fileLower.contains("avg") || fileLower.contains("average"))
    //               {
    //                  profile.setAverageLatencyPath(file);
    //                  File avgLatencyFile = new File(file);
    //                  try
    //                  {
    //                     BufferedReader reader = new BufferedReader(new FileReader(avgLatencyFile));
    //                     String line = reader.readLine(); // read first line.
    //                     String[] tokens = line.trim().split("\\s+");
    //                     int numTransactionType = tokens.length - 1;
    //                     for (int i = 0; i < numTransactionType; ++i)
    //                     {
    //                        profile.addTransactionType("Type " + (i+1));
    //                     }
    //                  }
    //                  catch (FileNotFoundException e)
    //                  {
    //                     JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    //                  }
    //                  catch (IOException e)
    //                  {
    //                     JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    //                  }
    //               }
    //               else if (fileLower.contains("trans_count"))
    //               {
    //                  profile.setTransCountPath(file);
    //               }
    //               else if (fileLower.contains("prctile_latencies.mat"))
    //               {
    //                  profile.setPercentileLatencyPath(file);
    //               }
    //               else if (fileLower.contains("stmt_count"))
    //               {
    //                  profile.setStatementStatPath(file);
    //               }
    //               else if (fileLower.contains("page"))
    //               {
    //                  profile.setPageInfoPath(file);
    //               }
    ////               else if( fileLower.contains("trans_types"))
    ////               {
    ////                  File typeFile = new File(file);
    ////                  try
    ////                  {
    ////                     BufferedReader reader = new BufferedReader(new FileReader(typeFile));
    ////                     String line = reader.readLine(); // read first line.
    ////                     String[] tokens = line.trim().split(",");
    ////                     for (String type : tokens)
    ////                     {
    ////
    ////                     }
    ////                     int numTransactionType = tokens.length;
    ////                     profile.setNumTransactionTypes(numTransactionType);
    ////                  }
    ////                  catch (FileNotFoundException e)
    ////                  {
    ////                     JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    ////                  }
    ////                  catch (IOException e)
    ////                  {
    ////                     JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    ////                  }
    ////               }
    //            }
    //         }
    //
    //         File dir = loadDialog.getFile();
    //         FileFilter filter = new WildcardFileFilter("prctile_latency_*");
    //         File[] latencies = dir.listFiles(filter);
    //         if (latencies.length > profile.getNumTransactionTypes())
    //         {
    //            for (int i = profile.getNumTransactionTypes(); i < latencies.length; ++i)
    //            {
    //               profile.addTransactionType("Type " + (i+1));
    //            }
    //         }
    //         profile.addTransactionRows();
    //      }
}

From source file:com.webcrawler.WebCrawlerMain.java

@Override
public void showMessageDialog(String message, String dialogHeader) {
    JOptionPane.showMessageDialog(this, message, dialogHeader, JOptionPane.INFORMATION_MESSAGE);
}

From source file:com.sec.ose.osi.sdk.protexsdk.project.ProjectAPIWrapper.java

public static boolean checkConnectToServer() {
    if (ProtexSDKAPIManager.getProjectAPI() == null) {
        JOptionPane.showMessageDialog(null, "Can't connect server to refresh project list", "Connection Error",
                JOptionPane.ERROR_MESSAGE);
        return false;
    }//from  www .  j  a v a2  s.  co m
    return true;
}