List of usage examples for javax.swing JDialog add
public Component add(Component comp)
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * creates the help menu item if it does not already exists * //from w w w. ja v a 2 s . co m * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiTextConfig.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiTextConfig.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulator.this, guiTextConfig.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiTextConfig.getString("AboutDialogTitle")); JLabel text = new JLabel(guiTextConfig.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item/*w w w . ja v a 2 s. com*/ * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiTextConfig.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiTextConfig.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiTextConfig.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiTextConfig.getString("AboutDialogTitle")); JLabel text = new JLabel(guiTextConfig.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * creates the help menu item if it does not already exists * /*from ww w . j a va2s . c om*/ * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulator.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item//from w w w . ja v a2s . c om * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.apache.tika.gui.TikaGUI.java
private void handleError(String name, Throwable t) { StringWriter writer = new StringWriter(); writer.append("Apache Tika was unable to parse the document\n"); writer.append("at " + name + ".\n\n"); writer.append("The full exception stack trace is included below:\n\n"); t.printStackTrace(new PrintWriter(writer)); JEditorPane editor = new JEditorPane("text/plain", writer.toString()); editor.setEditable(false);/*ww w. j a va2s .c om*/ editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); JDialog dialog = new JDialog(this, "Apache Tika error"); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); }
From source file:org.apache.tika.gui.TikaGUI.java
private void textDialog(String title, URL resource) { try {//from ww w .j a v a 2 s .c o m JDialog dialog = new JDialog(this, title); JEditorPane editor = new JEditorPane(resource); editor.setContentType("text/html"); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setPreferredSize(new Dimension(400, 250)); editor.addHyperlinkListener(this); dialog.add(editor); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.apache.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {/*from w w w . j a v a 2 s . c om*/ URL url = e.getURL(); try (InputStream stream = url.openStream()) { JEditorPane editor = new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8)); editor.setEditable(false); editor.setBackground(Color.WHITE); editor.setCaretPosition(0); editor.setPreferredSize(new Dimension(600, 400)); String name = url.toString(); name = name.substring(name.lastIndexOf('/') + 1); JDialog dialog = new JDialog(this, "Apache Tika: " + name); dialog.add(new JScrollPane(editor)); dialog.pack(); dialog.setVisible(true); } } catch (IOException exception) { exception.printStackTrace(); } } }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void showExampleInfo(String helpText) { final JDialog dialog = new JDialog(this); dialog.setLocationByPlatform(true);/*w w w . j av a 2s. c om*/ dialog.setPreferredSize(new Dimension(500, 250)); JComponent helpPane = TextComponentFactory.createTextPane(helpText, true); JButton closeButton = new JButton("Close"); closeButton.setMnemonic('c'); closeButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { dialog.dispose(); } }); JPanel panel = new JPanel(new BorderLayout()); panel.add(helpPane, BorderLayout.CENTER); panel.add(closeButton, BorderLayout.SOUTH); dialog.add(panel); dialog.pack(); dialog.setVisible(true); }
From source file:org.exist.launcher.Launcher.java
private boolean initSystemTray() { final Dimension iconDim = tray.getTrayIconSize(); BufferedImage image = null;// w ww . ja v a 2s . c o m try { image = ImageIO.read(getClass().getResource("icon32.png")); } catch (final IOException e) { showMessageAndExit("Launcher failed", "Failed to read system tray icon.", false); } trayIcon = new TrayIcon(image.getScaledInstance(iconDim.width, iconDim.height, Image.SCALE_SMOOTH), "eXist-db Launcher"); final JDialog hiddenFrame = new JDialog(); hiddenFrame.setUndecorated(true); hiddenFrame.setIconImage(image); final PopupMenu popup = createMenu(); trayIcon.setPopupMenu(popup); trayIcon.addActionListener(actionEvent -> { trayIcon.displayMessage(null, "Right click for menu", TrayIcon.MessageType.INFO); setServiceState(); }); // add listener for left click on system tray icon. doesn't work well on linux though. if (!SystemUtils.IS_OS_LINUX) { trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON1) { setServiceState(); hiddenFrame.add(popup); popup.show(hiddenFrame, mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen()); } } }); } try { hiddenFrame.setResizable(false); hiddenFrame.pack(); hiddenFrame.setVisible(true); tray.add(trayIcon); } catch (final AWTException e) { return false; } return true; }
From source file:org.gofleet.module.routing.RoutingMap.java
private void newPlan(LatLon from) { JDialog d = new JDialog(basicWindow.getFrame(), "Generating New Plan"); try {// www . j a v a2 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(); } }