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:br.com.topsys.cd.applet.AssinaturaApplet.java

public String assinar(String dados) {
    String retorno = null;/* ww w .  j av a  2  s  . c o  m*/

    try {

        X509Certificado certificadoAux = new X509Certificado(Base64.decodeBase64(this.certificado));

        if (certificadoAux.equals(this.certificadoDigital.getX509Certificado())) {

            if (super.flagListaCertificado) {
                Gson gson = new Gson();
                Map<Long, String> map = gson.fromJson(dados, HashMap.class);

                for (Map.Entry<Long, String> entry : map.entrySet()) {
                    entry.setValue(new AssinaturaDigital().assinar(this.certificadoDigital, entry.getValue()));

                }
                retorno = gson.toJson(map);
            } else {
                retorno = new AssinaturaDigital().assinar(this.certificadoDigital, dados);
            }

        } else {

            JOptionPane.showMessageDialog(null, "Certificado digital diferente do usurio do sistema!",
                    "Aviso", JOptionPane.ERROR_MESSAGE);
        }

    } catch (CertificadoDigitalException | ExcecaoX509 ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage(), "Aviso", JOptionPane.ERROR_MESSAGE);
        this.closeError();
    }

    return retorno;

}

From source file:com.redpill_linpro.libreoffice.LibreOfficeLauncherWindowsImpl.java

@Override
public void launchLibreOffice(String cmisUrl, String repositoryId, String filePath, String webdavUrl) {
    Runtime rt = Runtime.getRuntime();
    try {//from   www. java  2  s  .com
        String params;
        if (null != webdavUrl && webdavUrl.length() > 0) {
            params = LibreOfficeLauncherHelper.generateLibreOfficeWebdavOpenUrl(webdavUrl);
        } else {
            params = LibreOfficeLauncherHelper.generateLibreOfficeCmisOpenUrl(cmisUrl, repositoryId, filePath);
        }

        StringBuffer cmd = new StringBuffer();
        try {
            String[] binaryLocations = { "start soffice.exe" };

            for (int i = 0; i < binaryLocations.length; i++) {
                cmd.append((i == 0 ? "" : " || ") + binaryLocations[i] + " \"" + params + "\" ");
            }

            System.out.println("Command: cmd.exe /C " + cmd);

            rt.exec(new String[] { "cmd.exe", "/C", cmd.toString() });

            System.out.println("Process started");
        } catch (IOException e) {
            JOptionPane.showMessageDialog(null,
                    "Failed to start LibreOffice, commandline: " + cmd.toString() + "" + e.toString(), "Error",
                    JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }

    } catch (UnsupportedEncodingException e1) {
        JOptionPane.showMessageDialog(null, "Invalid URL for LibreOffice", "Error", JOptionPane.ERROR_MESSAGE);
        e1.printStackTrace();
    }

}

From source file:com.devbury.desktoplib.systemtray.SystemTrayApplication.java

public void start() {
    logSystemInfo();/*  w  w  w. j  a  v a  2  s  .c  o  m*/
    try {
        if (!isSystemTraySupported()) {
            JOptionPane.showMessageDialog(null,
                    "Could not start application.  This application requires system tray support and your platform "
                            + "does not provide this.",
                    "System Tray Not Supported", JOptionPane.ERROR_MESSAGE);
            throw new RuntimeException("SystemTray is not supported");
        } else {
            logger.debug("SystemTray is supported");
        }
        if (applicationContext == null) {
            String[] locations = buildConfigLocations();
            logger.debug("Creating context from " + configLocationsToString(locations));
            applicationContext = new ClassPathXmlApplicationContext(locations);
            logger.debug("Context finished building");
        }
        // get the TrayIconDefinition instances
        Map defs = applicationContext.getBeansOfType(TrayIconDefinition.class);
        if (defs == null || defs.isEmpty()) {
            throw new RuntimeException("No TrayIconDefinition instances exist in the context");
        }
        SystemTray tray = newSystemTray();
        Iterator<TrayIconDefinition> it = defs.values().iterator();
        LinkedList<TrayIcon> installedIcons = new LinkedList<TrayIcon>();
        while (it.hasNext()) {
            TrayIconDefinition def = (TrayIconDefinition) it.next();
            try {
                TrayIcon ti = def.buildTrayIcon();
                tray.add(ti);
                installedIcons.add(ti);
            } catch (Throwable t) {
                logger.error("Could not add TrayIconDefinition " + def);
            }
        }
        // get the monitor object out of the context to block on
        Object monitor = applicationContext.getBean("applicationShutdownService");

        // if there was a splash screen shut it down
        SplashScreen splash = newSplashScreen();
        if (splash != null) {
            logger.debug("Shutting down splash screen");
            splash.close();
        }

        synchronized (monitor) {
            monitor.wait();
        }
        logger.debug("Application shutting down");
        Iterator<TrayIcon> trayIconIt = installedIcons.iterator();
        while (trayIconIt.hasNext()) {
            TrayIcon ti = (TrayIcon) trayIconIt.next();
            tray.remove(ti);
        }
        applicationContext.close();
        logger.debug("Application stopped");
    } catch (Throwable t) {
        logger.error("Unresolved exception", t);
        logger.error("Application shutting down");
        if (applicationContext != null) {
            applicationContext.close();
        }
        logger.error("Application stopped");
    }
}

From source file:com.aw.swing.mvp.ui.msg.MessageDisplayerImpl.java

/**
 * Show a message used to inform to the user of something that happened
 *
 * @param message//from   ww w .j a  v  a 2s . co m
 */
public static void showMessage(Component parentContainer, String message) {
    ProcessMsgBlocker.instance().removeMessage();
    JOptionPane.showMessageDialog(parentContainer, message, GENERIC_MESSAGE_TITLE,
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:com.googlecode.logVisualizer.chart.AreaListChartMouseEventListener.java

public void chartMouseClicked(final ChartMouseEvent e) {
    if (e.getEntity() instanceof CategoryItemEntity) {
        final CategoryItemEntity entity = (CategoryItemEntity) e.getEntity();
        final String areaName = (String) entity.getColumnKey();

        final StringBuilder str = new StringBuilder(100);
        for (final TurnInterval ti : logData.getTurnIntervalsSpent())
            if (ti.getAreaName().equals(areaName))
                str.append(ti + "\n");

        final JScrollPane text = new JScrollPane(new JTextArea(str.toString()));
        text.setPreferredSize(new Dimension(450, 200));
        JOptionPane.showMessageDialog(null, text, "Occurences of turns spent at " + areaName,
                JOptionPane.INFORMATION_MESSAGE);
    }/*  w  w  w. j av a  2s . c o m*/
}

From source file:namedatabasescraper.NameDatabaseScraper.java

public void shutdown() {
    try {//w w  w. j a  v a2  s  .co m
        this.saveProperties();
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null,
                Utils.wordWrapString("Could not store properties: " + ex.getMessage(), 50),
                "Property storage failure", JOptionPane.ERROR_MESSAGE);
    }
    try {
        this.connection.close();
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null,
                Utils.wordWrapString("Could not close the database: " + ex.getMessage(), 50),
                "Database closing failure", JOptionPane.ERROR_MESSAGE);
    }
    logger.info("Exiting NameDatabaseScraper");
    System.exit(0);
}

From source file:Main.StaticTools.java

/**
 * Open up a <code> JOptionPane </code> with the given parameters
 * @param source description where the Exception is coming from, used as the header of the Pane
 * @param e the Exception which was thrown, will be prompted as the text of the Pane
 *//* w w  w. j a  v  a2s .c o  m*/
public static void errorOut(String source, Exception e) {
    JOptionPane.showMessageDialog(null, "From :" + source + "\nMessage: " + e.toString(), "Error",
            JOptionPane.ERROR_MESSAGE);
}

From source file:JOptionDemo.java

JOptionDemo(String s) {
    super(s);/*from www.  j  a  va  2s.c om*/

    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());

    JButton b = new JButton("Give me a message");
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(JOptionDemo.this, "This is your message: etaoin shrdlu",
                    "Coded Message", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    cp.add(b);

    b = new JButton("Goodbye!");
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    cp.add(b);

    // size the main window
    pack();
}

From source file:com.compomics.cell_coord.gui.controller.CellCoordController.java

/**
 * Show a message to the user.// ww w.j a v a  2 s. c o  m
 *
 * @param message
 * @param title
 * @param messageType
 */
public void showMessage(String message, String title, Integer messageType) {
    JOptionPane.showMessageDialog(cellCoordFrame.getContentPane(), message, title, messageType);
}

From source file:com.emr.schemas.SavedProcessesDataMover.java

/**
 * Constructor//from  ww  w . ja  va 2 s .com
 */
public SavedProcessesDataMover() {
    initComponents();
    this.setClosable(true);
    final Action processDelete = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            String foreignKeysTable = (String) tblProcesses.getModel().getValueAt(modelRow, 0);
            if (foreignKeysTable == null || "".equals(foreignKeysTable)) {
                JOptionPane.showMessageDialog(null, "Table is Empty", "Empty Table", JOptionPane.ERROR_MESSAGE);
            } else {

            }
        }

    };
    final SQLiteGetProcesses sp = new SQLiteGetProcesses();
    sp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            switch (event.getPropertyName()) {
            case "progress":
                System.out.println("Fetching data from db");
                break;
            case "state":
                switch ((SwingWorker.StateValue) event.getNewValue()) {
                case DONE:
                    try {
                        model = sp.get();
                        tblProcesses.setModel(model);
                        tblProcesses.getColumnModel().getColumn(0).setMaxWidth(300);
                        //hide irrelevant columns
                        tblProcesses.getColumnModel().getColumn(2).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(2).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(3).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(3).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(4).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(4).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(5).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(5).setMaxWidth(0);
                        tblProcesses.getColumnModel().getColumn(6).setMinWidth(0);
                        tblProcesses.getColumnModel().getColumn(6).setMaxWidth(0);

                        ButtonColumn buttonColumn = new ButtonColumn(tblProcesses, processDelete, 7, "Delete");
                    } catch (final CancellationException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        Logger.getLogger(SavedProcessesDataMover.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    break;
                }
                break;
            }
        }

    });
    sp.execute();

    tblProcesses.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                JTable target = (JTable) e.getSource();
                int rowIndex = target.getSelectedRow();
                String selectQry = (String) target.getModel().getValueAt(rowIndex, 2);
                String destinationTable = (String) target.getModel().getValueAt(rowIndex, 3);
                String truncateFirst = (String) target.getModel().getValueAt(rowIndex, 4);
                String destinationColumns = (String) target.getModel().getValueAt(rowIndex, 5);
                String columnsToBeMapped = (String) target.getModel().getValueAt(rowIndex, 6);
                lblUpdateText.setText("<html><b color='red'>Moving Data</b></html>");
                dbProgressBar.setIndeterminate(true);
                new DBUpdater(selectQry, destinationTable, truncateFirst, destinationColumns, columnsToBeMapped)
                        .execute();
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

}