Example usage for javax.swing JDialog setVisible

List of usage examples for javax.swing JDialog setVisible

Introduction

In this page you can find the example usage for javax.swing JDialog setVisible.

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Dialog depending on the value of parameter b .

Usage

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java

/**
 * Display a dialog box with a components license in it.
 * /*from  w  w  w  . j  a va  2s  .c o  m*/
 * @param ActionEvent
 * @return void
 */
private void viewLicense_actionPerformed(ActionEvent e) {

    int[] selectedRow = table.getSelectedRows();

    String license = "Select a component in order to view its license.";
    String componentName = null;
    if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) {

        int modelRow = table.convertRowIndexToModel(selectedRow[0]);
        license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.LICENSE_INDEX);
        componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel.NAME_INDEX);
    }

    JDialog licenseDialog = new JDialog();
    final JEditorPane jEditorPane = new JEditorPane("text/html", "");
    jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    jEditorPane.setText(license);
    if (jEditorPane.getCaretPosition() > 1) {
        jEditorPane.setCaretPosition(1);
    }
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    licenseDialog.setTitle(componentName + " License");
    licenseDialog.setContentPane(scrollPane);
    licenseDialog.setSize(400, 300);
    licenseDialog.setLocationRelativeTo(frame);
    licenseDialog.setVisible(true);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java

/**
 * Display a dialog box with a components license in it.
 * // w w w.  ja v  a 2s.c o m
 * @param ActionEvent
 * @return void
 */
private void viewLicense_actionPerformed(ActionEvent e) {

    int[] selectedRow = table.getSelectedRows();

    String license = "Select a component in order to view its license.";
    String componentName = null;
    if (selectedRow != null && selectedRow.length > 0 && selectedRow[0] >= 0) {

        int modelRow = table.convertRowIndexToModel(selectedRow[0]);
        license = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.LICENSE_INDEX);
        componentName = (String) ccmTableModel.getModelValueAt(modelRow, CCMTableModel2.NAME_INDEX);
    }

    JDialog licenseDialog = new JDialog();
    final JEditorPane jEditorPane = new JEditorPane("text/html", "");
    jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE);
    jEditorPane.setText(license);
    if (jEditorPane.getCaretPosition() > 1) {
        jEditorPane.setCaretPosition(1);
    }
    JScrollPane scrollPane = new JScrollPane(jEditorPane);
    licenseDialog.setTitle(componentName + " License");
    licenseDialog.setContentPane(scrollPane);
    licenseDialog.setSize(400, 300);
    licenseDialog.setLocationRelativeTo(frame);
    licenseDialog.setVisible(true);
}

From source file:org.geworkbench.engine.ccm.DependencyManager.java

void checkDependency() {
    // in case other component does not like this
    Object oldSetting = UIManager.get("Button.defaultButtonFollowsFocus");
    UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
    JDialog dialog = optionPane.createDialog(null, "Dependency Checking Dialog");

    dialog.setVisible(true);
    Object obj = optionPane.getValue();
    UIManager.put("Button.defaultButtonFollowsFocus", oldSetting); // restore
    if (obj == null) {
        rollBack();/*from w w w.  j av  a  2s .  c o  m*/
        return;
    }
    String selectedValue = (String) optionPane.getValue();
    if (selectedValue.equals("Continue")) {
        switch (changeFlag) {
        case LOAD:
            updateRequired();
            break;
        case UNLOAD:
            updateDependent();
            break;
        default:
            log.error("invalid flag independency manager");
        }
        return;
    } else { // if not "Continue"
        rollBack();
    }
}

From source file:org.giswater.controller.MenuController.java

public void downloadNewVersion() {

    Utils.getLogger().info("Downloading last version...");

    if (ftp == null)
        return;//from  w  w  w.ja v  a2  s.co m

    String ftpVersion = ftp.getFtpVersion();
    String remoteName = UPDATE_FILE + ftpVersion + ".exe";
    // Choose file to download
    mainFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    String localePath = chooseFileSetup(remoteName);
    if (!localePath.equals("")) {
        DownloadPanel panel = new DownloadPanel(remoteName, localePath, ftp);
        JDialog downloadDialog = Utils.openDialogForm(panel, mainFrame,
                Utils.getBundleString("MenuController.download_process"), 290, 135); //$NON-NLS-1$
        downloadDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        downloadDialog.setVisible(true);
        mainFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }

}

From source file:org.gofleet.module.routing.RoutingMap.java

private void newPlan(LatLon from) {
    JDialog d = new JDialog(basicWindow.getFrame(), "Generating New Plan");
    try {// w ww .jav  a 2 s . co  m
        JFileChooser fc = new JFileChooser();
        fc.addChoosableFileFilter(new RoutingFilter());
        fc.setAcceptAllFileFilterUsed(true);
        int returnVal = fc.showOpenDialog(basicWindow.getFrame());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            log.debug("Opening: " + file.getName());

            JProgressBar progressBar = new JProgressBar(0, getNumberLines(file) * 2);
            progressBar.setValue(0);
            progressBar.setPreferredSize(new Dimension(150, 50));
            progressBar.setStringPainted(true);

            d.add(progressBar);
            d.pack();
            d.setVisible(true);

            TSPPlan[] param = processFile(file, progressBar);

            Map<String, String> values = getValues(from);

            double[] origin = new double[2];
            origin[0] = new Double(values.get("origin_x"));
            origin[1] = new Double(values.get("origin_y"));

            TSPPlan[] res = calculateRouteOnWS(new Integer(values.get("maxDistance")),
                    new Integer(values.get("maxTime")), origin, new Integer(values.get("startTime")), param,
                    new Integer(values.get("timeSpentOnStop")));

            progressBar.setValue(progressBar.getMaximum() - res.length);

            processTSPPlan(res, progressBar);

        } else {
            log.trace("Open command cancelled by user.");
        }
    } catch (Throwable t) {
        log.error("Error computing new plan", t);
        JOptionPane.showMessageDialog(basicWindow.getFrame(),
                "<html><p>" + i18n.getString("Main.Error") + ":</p><p>" + t.toString() + "</p><html>",
                i18n.getString("Main.Error"), JOptionPane.ERROR_MESSAGE);
    } finally {
        d.setVisible(false);
        d.dispose();
    }

}

From source file:org.gofleet.module.routing.RoutingMap.java

private Map<String, String> getValues(LatLon from) {
    final Map<String, String> mapa = new HashMap<String, String>();
    final JDialog frame = new JDialog(basicWindow.getFrame(), "Configuration");
    JPanel panel = new JPanel(new GridLayout(0, 2));
    int width = 10;

    final JTextField maxDistance = new JTextField(width);
    maxDistance.setText("10");
    final JTextField maxTime = new JTextField(width);
    maxTime.setText("8");
    final JTextField origin_x = new JTextField(width / 2);
    origin_x.setText((new Double(from.getX())).toString());
    final JTextField origin_y = new JTextField(width / 2);
    origin_y.setText((new Double(from.getY())).toString());
    final JTextField startTime = new JTextField(width);
    startTime.setText("7");
    final JTextField timeSpentOnStop = new JTextField(width);
    timeSpentOnStop.setText("1");
    JLabel lmaxDistance = new JLabel("Maximum Distance (km)");
    lmaxDistance.setLabelFor(maxDistance);
    JLabel lmaxTime = new JLabel("Maximum Time (hours)");
    lmaxTime.setLabelFor(maxTime);//  w  ww  . j  a  v  a 2s . c  o  m
    JLabel lorigin = new JLabel("Point of Origin");
    lorigin.setLabelFor(origin_x);
    JLabel lstartTime = new JLabel("Start Time of Plan (0-24)");
    lstartTime.setLabelFor(startTime);
    JLabel ltimeSpentOnStop = new JLabel("Time Spent on Stop (hours)");
    ltimeSpentOnStop.setLabelFor(timeSpentOnStop);

    JButton close = new JButton("OK");
    close.addActionListener(new AbstractAction() {

        private static final long serialVersionUID = -8912729211256933464L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                mapa.put("maxDistance", maxDistance.getText());
                mapa.put("maxTime", maxTime.getText());
                mapa.put("origin_x", origin_x.getText());
                mapa.put("origin_y", origin_y.getText());
                mapa.put("startTime", startTime.getText());
                mapa.put("timeSpentOnStop", timeSpentOnStop.getText());
                frame.dispose();
            } catch (Throwable t) {
                log.error("Error configuring New Route Plan" + t);
                JOptionPane.showMessageDialog(RoutingMap.this, "Some values are wrong. Check them again.");
            }
        }
    });

    panel.add(lmaxDistance);
    panel.add(maxDistance);
    panel.add(lmaxTime);
    panel.add(maxTime);
    panel.add(lorigin);
    JPanel panel_origin = new JPanel();
    panel_origin.add(origin_x);
    panel_origin.add(origin_y);
    panel.add(panel_origin);
    panel.add(lstartTime);
    panel.add(startTime);
    panel.add(ltimeSpentOnStop);
    panel.add(timeSpentOnStop);
    panel.add(close);
    frame.add(panel, BorderLayout.CENTER);
    frame.pack();
    frame.setModalityType(ModalityType.APPLICATION_MODAL);
    frame.setVisible(true);

    return mapa;
}

From source file:org.gtdfree.GTDFree.java

/**
 * This method initializes jMenuItem   //  w w  w  .jav a  2 s.com
 *    
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getAboutMenuItem() {
    if (aboutMenuItem == null) {
        aboutMenuItem = new JMenuItem();
        aboutMenuItem.setText(Messages.getString("GTDFree.Help.About")); //$NON-NLS-1$
        aboutMenuItem.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_about));
        aboutMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JDialog aboutDialog = getAboutDialog();
                //aboutDialog.pack();
                Point loc = getJFrame().getLocation();
                loc.translate(20, 20);
                aboutDialog.setLocation(loc);
                aboutDialog.setVisible(true);
            }
        });
    }
    return aboutMenuItem;
}

From source file:org.interreg.docexplore.authoring.AuthoringMenu.java

public AuthoringMenu(final AuthoringToolFrame authoringTool) {
    this.tool = authoringTool;

    this.recent = new LinkedList<String>();
    readRecent();/*from  w ww .  ja va  2  s.  c o  m*/
    this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile"));
    add(file);

    newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) {
        public void actionPerformed(ActionEvent arg0) {
            newFile();
        }
    });
    loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) {
        public void actionPerformed(ActionEvent arg0) {
            load();
        }
    });
    saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) {
        public void actionPerformed(ActionEvent arg0) {
            save();
        }
    });
    saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) {
        public void actionPerformed(ActionEvent arg0) {
            saveAs();
        }
    });
    exportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.readerExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (float) authoringTool.readerExporter.progress[0];
                        }
                    }, authoringTool.editor);
                }
            });
    webExportItem = new JMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") {
                public void actionPerformed(ActionEvent arg0) {
                    GuiUtils.blockUntilComplete(new ProgressRunnable() {
                        public void run() {
                            try {
                                authoringTool.webExporter.doExport(authoringTool.editor.link);
                            } catch (Exception ex) {
                                ErrorHandler.defaultHandler.submit(ex);
                            }
                        }

                        public float getProgress() {
                            return (authoringTool.webExporter.copyComplete ? .5f : 0f)
                                    + (float) (.5 * authoringTool.webExporter.progress[0]);
                        }
                    }, authoringTool.editor);
                }
            });
    //      webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0)
    //      {
    //         GuiUtils.blockUntilComplete(new Runnable() {public void run()
    //         {
    //            try 
    //            {
    //               new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0)));
    //            }
    //            catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);}
    //         }}, authoringTool.editor);
    //      }});
    //      webExportItem.setEnabled(false);
    quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) {
        public void actionPerformed(ActionEvent arg0) {
            authoringTool.quit();
        }
    });
    buildFileMenu();

    JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit"));
    this.undoItem = new JMenuItem();
    undoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.undo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(undoItem);
    this.redoItem = new JMenuItem();
    redoItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                authoringTool.historyManager.redo();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    });
    edit.add(redoItem);
    JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory"));
    viewHistory.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.historyDialog.setVisible(true);
        }
    });
    edit.add(viewHistory);

    edit.addSeparator();

    edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) {
        public void actionPerformed(ActionEvent arg0) {
            Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"),
                    XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null,
                    new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"),
                            XMLResourceBundle.getBundledString("fixCharsMac") },
                    XMLResourceBundle.getBundledString("fixCharsWin"));
            if (res == null)
                return;
            try {
                convertPresentation(tool.defaultFile,
                        res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1"
                                : "x-MacRoman");
            } catch (Exception e) {
                ErrorHandler.defaultHandler.submit(e);
            }
            try {
                tool.editor.reset();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }));

    //TODO: remove!
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               if (regions.size() > 2)
    //               {
    //                  Region highest = null;
    //                  int max = -1;
    //                  for (Region region : regions)
    //                     for (Point point : region.getOutline())
    //                        if (max < 0 || point.y < max)
    //                           {max = point.y; highest = region;}
    //                  Region middle = null;
    //                  max = -1;
    //                  for (Region region : regions)
    //                     if (region != highest)
    //                        for (Point point : region.getOutline())
    //                           if (max < 0 || point.y < max)
    //                              {max = point.y; middle = region;}
    //                  if (regions.size() > 3)
    //                  {
    //                     max = -1;
    //                     Region newMiddle = null;
    //                     for (Region region : regions)
    //                        if (region != highest && region != middle)
    //                           for (Point point : region.getOutline())
    //                              if (max < 0 || point.y < max)
    //                                 {max = point.y; newMiddle = region;}
    //                     middle = newMiddle;
    //                  }
    //                  MetaDataKey display = book.getLink().getKey("display", "");
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet())
    //                     for (MetaData md : entry.getValue())
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = "<b>"+md.getString()+"</b>\n";
    //                           for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                              for (MetaData md2 : entry2.getValue())
    //                                 if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager))
    //                                    val = val+"\n"+md2.getString();
    //                           md.setString(val);
    //                        }
    //                  boolean hasImage = false;
    //                  for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet())
    //                     for (MetaData md2 : entry2.getValue())
    //                        if (md2.getType().equals(MetaData.imageType))
    //                        {
    //                           MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue());
    //                           if (!hasImage)
    //                              BookImporter.insert(imageMd, highest, 0);
    //                           else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1);
    //                           hasImage = true;
    //                        }
    //                  page.removeRegion(middle);
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  List<MetaData> mds = region.getMetaDataListForKey(display);
    //                     for (MetaData md : mds)
    //                        if (md.getType().equals(MetaData.textType))
    //                        {
    //                           String val = md.getString().trim();
    //                           if (!val.startsWith("<i>") || !val.endsWith("</i>"))
    //                              continue;
    //                           TextElement.getStyleMD(md).setString("4");
    //                           md.setString(val.substring(3, val.length()-4));
    //                           System.out.println(md.getString());
    //                        }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            int lastPage = book.getLastPageNumber();
    //            MetaDataKey display = book.getLink().getKey("display", "");
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               Set<Region> regions = page.getRegions();
    //               for (Region region : regions)
    //               {
    //                  int max = BookImporter.getHighestRank(region);
    //                  for (int i=0;i<max;i++)
    //                  {
    //                     MetaData md1 = BookImporter.getAtRank(region, i);
    //                     if (md1 == null || !md1.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style1 = TextElement.getStyleMD(md1);
    //                     if (!style1.getString().equals("0"))
    //                        continue;
    //                     MetaData md2 = BookImporter.getAtRank(region, i+1);
    //                     if (md2 == null || !md2.getType().equals(MetaData.textType))
    //                        continue;
    //                     MetaData style2 = TextElement.getStyleMD(md2);
    //                     if (!style2.getString().equals("1"))
    //                        continue;
    //                     BookImporter.setRank(md1, i+1);
    //                     BookImporter.setRank(md2, i);
    //                     i++;
    //                  }
    //               }
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));
    //      edit.add(new JMenuItem(new AbstractAction("hack!")
    //      {
    //         public void actionPerformed(ActionEvent e) {try
    //         {
    //            BookEditorView be = null;
    //            for (ExplorerView view : tool.editor.views)
    //               if (view instanceof BookEditorView)
    //                  be = (BookEditorView)view;
    //            Book book = be.curBook;
    //            MetaDataKey mini = book.getLink().getOrCreateKey("mini", "");
    //            MetaDataKey dim = book.getLink().getOrCreateKey("dimension", "");
    //            int lastPage = book.getLastPageNumber();
    //            for (int pageNum = 1;pageNum <= lastPage;pageNum++)
    //            {
    //               Page page = book.getPage(pageNum);
    //               List<MetaData> mds = page.getMetaDataListForKey(mini);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               mds = page.getMetaDataListForKey(dim);
    //               if (mds != null)
    //                  for (MetaData md : mds)
    //                     page.removeMetaData(md);
    //               DocExploreDataLink.getImageDimension(page, true);
    //               DocExploreDataLink.getImageMini(page, false);
    //            }
    //         }
    //         catch (Exception ex) {ex.printStackTrace();}System.out.println("done");}
    //      }));

    add(edit);

    JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView"));
    add(view);

    JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...",
            ImageUtils.getIcon("pencil-24x24.png"));
    styles.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            authoringTool.styleManager.styleDialog.setVisible(true);
        }
    });
    view.add(styles);

    helpToggle = new JCheckBoxMenuItem(
            new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) {
                public void actionPerformed(ActionEvent arg0) {
                    authoringTool.displayHelp = helpToggle.isSelected();
                    authoringTool.repaint();
                }
            });
    helpToggle.setSelected(tool.startup.showHelp);
    view.add(helpToggle);

    JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp"));
    if (Desktop.isDesktopSupported()) {
        final Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm");
                        desktop.open(doc);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
            helpMenu.add(new AbstractAction(
                    XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) {
                public void actionPerformed(ActionEvent e) {
                    try {
                        File link = new File(DocExploreTool.getExecutableDir(), "website.url");
                        desktop.open(link);
                    } catch (Exception ex) {
                        ErrorHandler.defaultHandler.submit(ex, true);
                    }
                }
            });
        }
    }
    helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) {
        public void actionPerformed(ActionEvent e) {
            final JDialog splash = new JDialog(tool, true);
            splash.setLayout(new BorderLayout());
            SplashScreen screen = new SplashScreen("logoAT.png");
            splash.add(screen, BorderLayout.NORTH);
            screen.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    splash.setVisible(false);
                }
            });
            splash.setUndecorated(true);
            screen.setText(
                    "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>");
            splash.pack();
            splash.setAlwaysOnTop(true);
            GuiUtils.centerOnScreen(splash);
            splash.setVisible(true);
        }
    });
    add(helpMenu);

    historyChanged(authoringTool.historyManager);
    authoringTool.historyManager.addHistoryListener(this);
}

From source file:org.interreg.docexplore.DocExploreTool.java

@SuppressWarnings("serial")
protected static File askForHome(String text) {
    final File[] file = { null };
    final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true);
    JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER,
            SwingConstants.TOP, true, false));
    content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
    JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT);
    message.setIconTextGap(20);//from  ww  w  .j a  va 2  s.  c  om
    //message.setFont(Font.decode(Font.SANS_SERIF));
    content.add(message);

    final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>"));
    final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore",
            40);
    pathPanel.add(pathField);
    pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) {
        JNativeFileDialog nfd = null;

        public void actionPerformed(ActionEvent arg0) {
            if (nfd == null) {
                nfd = new JNativeFileDialog();
                nfd.acceptFiles = false;
                nfd.acceptFolders = true;
                nfd.multipleSelection = false;
                nfd.title = XMLResourceBundle.getBundledString("homeLabel");
            }
            nfd.setCurrentFile(new File(pathField.getText()));
            if (nfd.showOpenDialog())
                pathField.setText(nfd.getSelectedFile().getAbsolutePath());
        }
    }));
    content.add(pathPanel);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) {
        public void actionPerformed(ActionEvent e) {
            File res = new File(pathField.getText());
            if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs())
                JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"),
                        XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE);
            else {
                file[0] = res;
                dialog.setVisible(false);
            }
        }
    }));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    }));
    content.add(buttonPanel);

    dialog.getContentPane().add(content);
    dialog.pack();
    dialog.setResizable(false);
    GuiUtils.centerOnScreen(dialog);
    dialog.setVisible(true);
    return file[0];
}

From source file:org.jab.docsearch.DocSearch.java

/**
 * Does the actual work for Displaying an informational dialog - invoked via
 * a MessageRunner so as not to be on the dispatch (GUI) thread
 *
 * @see MessageRunner//from  www. jav a2s  .c o  m
 */
public void showMessageDialog(String title, String body) {
    if (!isLoading && env.isGUIMode()) {
        int messageType = JOptionPane.INFORMATION_MESSAGE;
        if (title.toLowerCase().indexOf(I18n.getString("lower_error")) != -1) {
            messageType = JOptionPane.ERROR_MESSAGE;
        }

        JOptionPane pane = new JOptionPane(body, messageType);
        JDialog dialog = pane.createDialog(this, title);
        dialog.setVisible(true);
    } else {
        logger.info("showMessageDialog() \n* * * " + title + " * * *\n\t" + body);
    }
}