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:latexstudio.editor.DbxFileActions.java

/**
 * Saves progress to dropbox and updates file history (DropboxRevisions)
 *
 * @param drtc to be updated with a new entry (file history)
 *//*from  w w  w  .j  a v a 2  s  .c o  m*/
public void saveProgress(DbxClient client, DropboxRevisionsTopComponent drtc) {
    DbxState dbxState = etc.getDbxState();

    if (client == null) {
        return;
    }

    File file = new File(ApplicationUtils.getTempSourceFile());

    try (FileInputStream inputStream = new FileInputStream(file)) {
        if (dbxState != null) {
            try {
                DbxEntry.File uploadedFile = client.uploadFile(dbxState.getPath(),
                        DbxWriteMode.update(dbxState.getRevision()), file.length(), inputStream);
                JOptionPane.showMessageDialog(null,
                        "Successfuly updated file " + uploadedFile.name + " (" + uploadedFile.humanSize + ")",
                        "File updated in Dropbox", JOptionPane.INFORMATION_MESSAGE);
                drtc.updateRevisionsList(uploadedFile.path);
                etc.setDbxState(new DbxState(uploadedFile.path, uploadedFile.rev));
            } catch (DbxException ex) {
                DbxUtil.showDbxAccessDeniedPrompt();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            } finally {
                IOUtils.closeQuietly(inputStream);
                etc.setModified(false);
            }
        } else {
            JOptionPane.showMessageDialog(null,
                    "No Dropbox file has been loaded.\n" + "You must open Dropbox file, before you save it.",
                    "Cannot save progress", JOptionPane.WARNING_MESSAGE);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:Main.java

public void setPath(String filePath) {
    Node root = null;/*w w  w.j av a2s . com*/
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(filePath);
        root = (Node) doc.getDocumentElement();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Can't parse file", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    if (root != null) {
        dtModel = new DefaultTreeModel(builtTreeNode(root));
        this.setModel(dtModel);
    }
}

From source file:rhinova.gui.dataentry.link.LinkDataEntryPanel.java

private void btnCreateActionPerformed(ActionEvent ev) {
    try {/*from   w w  w. ja  v  a2  s . c  om*/
        // test if the Tableable object can be created
        linkList.createTableable(getUserInputArray());

        // ask for confirmation
        int response = JOptionPane.showConfirmDialog(null, "Do you wish to create this Componenet?", "Confirm?",
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (response == 0) {
            // create the object
            linkList.createAndAddNewInstance(getUserInputArray());
            JOptionPane.showMessageDialog(null, "Model Component Created", "Success",
                    JOptionPane.INFORMATION_MESSAGE);
        }
        // report exceptions to the user
    } catch (IncorrectDataType e) {
        EntityExceptionDialogs.onIncorrectDataType(e.getMessage());
    } catch (ConstraintViolatedException e) {
        EntityExceptionDialogs.onConstraintViolateException(e.getMessage());
    } catch (NullInputException e) {
        EntityExceptionDialogs.onNullInputException(e.getMessage());
    }
}

From source file:mobac.program.EnvironmentSetup.java

public static void checkMemory() {
    Runtime r = Runtime.getRuntime();
    long maxHeap = r.maxMemory();
    String heapMBFormatted = String.format(Locale.ENGLISH, "%3.2f MiB", maxHeap / 1048576d);
    log.info("Total available memory to MOBAC: " + heapMBFormatted);
    if (maxHeap < 200000000) {
        String msg = "<html><b>WARNING:</b> Mobile Atlas Creator has been started "
                + "with a very small amount of memory assigned.<br>"
                + "The current maximum usable amount of memory to Mobile Atlas Creator is <b>" + heapMBFormatted
                + "</b>.<br><br>Please make sure to start Mobile Atlas Creator in "
                + "the future via the provided start scripts <i>Mobile Atlas Creator.exe</i><br>"
                + "on Windows or <i>start.sh</i> on Linux/Unix/OSX or add the "
                + "parameter <b>-Xmx 512M</b> to your startup command.<br><br>"
                + "Example: <i>java -Xmx512M -jar Mobile_Atlas_Creator.jar</i><br>"
                + "<br><center>Press OK to continue and start Mobile Atlas Creator</center></html>";
        JOptionPane.showMessageDialog(null, msg, "Warning: low memory", JOptionPane.WARNING_MESSAGE);
    }// ww w  .j  av a  2 s  .  co  m
}

From source file:MainClass.java

protected void showMessage(Object source) {
    if (source instanceof Component) {
        JOptionPane.showMessageDialog((Component) source, errorMessage, errorTitle,
                JOptionPane.WARNING_MESSAGE);
    } else {/*from  w  ww .j av  a 2 s .com*/
        System.err.println(errorMessage);
    }
}

From source file:fxts.stations.transport.tradingapi.processors.BusinessMessageRejectProcessor.java

public void process(ITransportable aTransportable) {
    TradingServerSession aTradingServerSession = TradingServerSession.getInstance();
    final BusinessMessageReject aBmr = (BusinessMessageReject) aTransportable;
    mLogger.debug("client inc: business message request = " + aBmr);
    String reqID = aTradingServerSession.getRequestID();
    if (reqID != null && reqID.equals(aBmr.getBusinessRejectRefID())) {
        aTradingServerSession.doneProcessing();
    } else {/*  w  ww . ja va  2  s  .  co  m*/
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                MainFrame mainFrame = TradeApp.getInst().getMainFrame();
                JOptionPane.showMessageDialog(mainFrame, OraCodeFactory.toMessage(aBmr.getText()),
                        "Problem with your request..", JOptionPane.ERROR_MESSAGE);
            }
        });
    }
}

From source file:EditorPaneSample.java

public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
    HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
    final URL url = hyperlinkEvent.getURL();
    if (type == HyperlinkEvent.EventType.ENTERED) {
        System.out.println("URL: " + url);
    } else if (type == HyperlinkEvent.EventType.ACTIVATED) {
        System.out.println("Activated");
        Runnable runner = new Runnable() {
            public void run() {
                // Retain reference to original
                Document doc = editorPane.getDocument();
                try {
                    editorPane.setPage(url);
                } catch (IOException ioException) {
                    JOptionPane.showMessageDialog(frame, "Error following link", "Invalid link",
                            JOptionPane.ERROR_MESSAGE);
                    editorPane.setDocument(doc);
                }//from  ww w.  j av  a 2s. co  m
            }
        };
        SwingUtilities.invokeLater(runner);
    }
}

From source file:rhinova.gui.dataentry.reserve.ReserveDataEntryPanel.java

private void btnCreateReserveActionPerformed(ActionEvent ev) {
    try {/*from w  ww . j  av a 2s  .c  o  m*/
        // test if the Tableable object can be created
        reserveList.createTableable(getUserInputArray());

        // ask for confirmation
        int response = JOptionPane.showConfirmDialog(null, "Do you wish to create this Componenet?", "Confirm?",
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (response == 0) {
            // create the object
            reserveList.createAndAddNewInstance(getUserInputArray());
            JOptionPane.showMessageDialog(null, "Model Component Created", "Success",
                    JOptionPane.INFORMATION_MESSAGE);
        }
        // report exceptions to the user
    } catch (IncorrectDataType e) {
        EntityExceptionDialogs.onIncorrectDataType(e.getMessage());
    } catch (ConstraintViolatedException e) {
        EntityExceptionDialogs.onConstraintViolateException(e.getMessage());
    } catch (NullInputException e) {
        EntityExceptionDialogs.onNullInputException(e.getMessage());
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.addserverwizard.AddServerWizard.java

public AddServerWizard(final JFrame parent, final GUI gui) {
    this.parent = parent;
    this.gui = gui;

    // Only show the choose provider page if more than one provider is
    // available.
    final AddServerWizardDataRecorder rec = new AddServerWizardDataRecorder();

    WizardPage firstPage = null;//from w  w w  . ja  va 2 s. c om

    switch (CloudManager.get().getLinkedCloudProviderNames().size()) {
    case 0:
        JOptionPane.showMessageDialog(parent, "Please add a new CloudProvider before starting new servers.",
                "First add Provider", JOptionPane.ERROR_MESSAGE);
        final AddProviderWizard wiz = new AddProviderWizard();
        wiz.startModal(parent);
        return;
    case 1: // One provider -- user has to pick this one so skip the
            // page
        final CloudProvider prov = (CloudProvider) CloudManager.get().getLinkedCloudProviders().toArray()[0];
        rec.provider = prov;
        firstPage = new ChooseImagePage(prov);
        break;
    default:
        firstPage = new ChooseProviderPage();
        break;
    }
    final Wizard wiz = new Wizard(firstPage, rec, new SimpleWizardTemplate());
    wiz.addWizardListener(this);
    wiz.startModal("Start new server", 500, 400, parent);
}

From source file:namedatabasescraper.MainWindow.java

/**
 * A single-access point for reporting exceptions to the user.
 *
 * @param message/*from   w  w  w.j ava2 s  .  co m*/
 */
public void reportException(String message) {
    JOptionPane.showMessageDialog(this, Utils.wordWrapString(message, 50), "Program error",
            JOptionPane.ERROR_MESSAGE);
}