List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:org.apache.tika.gui.TikaGUI.java
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == EventType.ACTIVATED) { try {// w w w . jav a2 s. co m 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.broad.igv.track.TrackMenuUtils.java
public static JMenuItem getRemoveMenuItem(final Collection<Track> selectedTracks) { boolean multiple = selectedTracks.size() > 1; JMenuItem item = new JMenuItem("Remove Track" + (multiple ? "s" : "")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (selectedTracks.isEmpty()) { return; }/*from w w w . j a va2 s. c o m*/ StringBuffer buffer = new StringBuffer(); for (Track track : selectedTracks) { buffer.append("\n\t"); buffer.append(track.getName()); } String deleteItems = buffer.toString(); JTextArea textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); textArea.setText(deleteItems); JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION); optionPane.setPreferredSize(new Dimension(550, 500)); JDialog dialog = optionPane.createDialog(IGV.getMainFrame(), "Remove The Following Tracks"); dialog.setVisible(true); Object choice = optionPane.getValue(); if ((choice == null) || (JOptionPane.YES_OPTION != ((Integer) choice).intValue())) { return; } IGV.getInstance().removeTracks(selectedTracks); IGV.getInstance().doRefresh(); } }); return item; }
From source file:org.deegree.tools.rendering.viewer.File3dImporter.java
public static List<WorldRenderableObject> open(Frame parent, String fileName) { if (fileName == null || "".equals(fileName.trim())) { throw new InvalidParameterException("the file name may not be null or empty"); }/*from www . j a v a 2 s . c o m*/ fileName = fileName.trim(); CityGMLImporter openFile2; XMLInputFactory fac = XMLInputFactory.newInstance(); InputStream in = null; try { XMLStreamReader reader = fac.createXMLStreamReader(in = new FileInputStream(fileName)); reader.next(); String ns = "http://www.opengis.net/citygml/1.0"; openFile2 = new CityGMLImporter(null, null, null, reader.getNamespaceURI().equals(ns)); } catch (Throwable t) { openFile2 = new CityGMLImporter(null, null, null, false); } finally { IOUtils.closeQuietly(in); } final CityGMLImporter openFile = openFile2; final JDialog dialog = new JDialog(parent, "Loading", true); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add( new JLabel("<HTML>Loading file:<br>" + fileName + "<br>Please wait!</HTML>", SwingConstants.CENTER), BorderLayout.NORTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setIndeterminate(false); dialog.getContentPane().add(progressBar, BorderLayout.CENTER); dialog.pack(); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); dialog.setLocationRelativeTo(parent); final Thread openThread = new Thread() { /** * Opens the file in a separate thread. */ @Override public void run() { // openFile.openFile( progressBar ); if (dialog.isDisplayable()) { dialog.setVisible(false); dialog.dispose(); } } }; openThread.start(); dialog.setVisible(true); List<WorldRenderableObject> result = null; try { result = openFile.importFromFile(fileName, 6, 2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } gm = openFile.getQmList(); // // if ( result != null ) { // openGLEventListener.addDataObjectToScene( result ); // File f = new File( fileName ); // setTitle( WIN_TITLE + f.getName() ); // } else { // showExceptionDialog( "The file: " + fileName // + " could not be read,\nSee error log for detailed information." ); // } return result; }
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void showExampleInfo(String helpText) { final JDialog dialog = new JDialog(this); dialog.setLocationByPlatform(true);/*from w ww .ja v a2s .com*/ 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.executequery.gui.browser.SSHTunnelConnectionPanel.java
public boolean canConnect() { if (useSshCheckbox.isSelected()) { if (!hasValue(userNameField)) { GUIUtilities//from w w w. ja v a2 s . c o m .displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH user name"); return false; } if (!hasValue(portField)) { GUIUtilities.displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH port"); return false; } if (!hasValue(passwordField)) { final JPasswordField field = WidgetFactory.createPasswordField(); JOptionPane optionPane = new JOptionPane(field, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog("Enter SSH password"); dialog.addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { field.requestFocusInWindow(); } }); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); dialog.setVisible(true); dialog.dispose(); int result = Integer.parseInt(optionPane.getValue().toString()); if (result == JOptionPane.OK_OPTION) { String password = MiscUtils.charsToString(field.getPassword()); if (StringUtils.isNotBlank(password)) { passwordField.setText(password); return true; } else { GUIUtilities.displayErrorMessage( "You have selected SSH Tunnel but have not provided an SSH password"); // send back here and force them to select cancel if they want to bail return canConnect(); } } return false; } } return true; }
From source file:org.exist.launcher.Launcher.java
private boolean initSystemTray() { final Dimension iconDim = tray.getTrayIconSize(); BufferedImage image = null;//from w w w. j a v a2s. c om 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.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java
/** * This method initializes jButton//from w w w.j a v a 2 s .co m * * @return javax.swing.JButton */ private JButton getJButtonFillGraphic() { if (jButtonFillGraphic == null) { jButtonFillGraphic = new JButton(); boolean enabled = false; if (symbolizer.getFill() != null) { Graphic graphicFill = symbolizer.getFill().getGraphicFill(); enabled = (graphicFill != null); } jButtonFillGraphic.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (symbolizer.getFill() == null) { symbolizer.setFill(StylingUtil.STYLE_BUILDER.createFill((Color) null, (Color) null, 1., StylingUtil.STYLE_BUILDER.createGraphic())); } JDialog editFillGraphicJDialog = new GraphicEditGUIinDialog(asv, SwingUtil.getParentWindow(PolygonSymbolEditGUI.this), symbolizer.getFill()); editFillGraphicJDialog.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(AbstractStyleEditGUI.PROPERTY_UPDATED)) { PolygonSymbolEditGUI.this.firePropertyChange(AbstractStyleEditGUI.PROPERTY_UPDATED, null, null); // Update the Button Icon jButtonFillGraphic.setIcon(new ImageIcon(ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } }); SwingUtil.setRelativeFramePosition(editFillGraphicJDialog, PolygonSymbolEditGUI.this, SwingUtil.BOUNDS_OUTER, SwingUtil.NORTHEAST); editFillGraphicJDialog.setVisible(true); } }); // Initialize correctly jLabelFillGraphic.setEnabled(enabled); jButtonFillGraphic.setEnabled(enabled); if (enabled) { jButtonFillGraphic.setIcon(new ImageIcon( ASUtil.getSymbolizerImage(symbolizer, FeatureUtil.createFeatureType(Polygon.class)))); } } return jButtonFillGraphic; }
From source file:org.geopublishing.atlasViewer.GpCoreUtil.java
public static JDialog getWaitDialog(final Component owner, final String msg) { final JDialog waitFrame = new JDialog(SwingUtil.getParentWindow(owner)); waitFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final JPanel cp = new JPanel(new MigLayout()); final JLabel label = new JLabel(msg, Icons.ICON_TASKRUNNING_BIG, SwingConstants.LEADING); cp.add(label);/*ww w .j a v a 2s.c o m*/ waitFrame.setContentPane(cp); waitFrame.setAlwaysOnTop(true); waitFrame.pack(); SwingUtil.centerFrameOnScreen(waitFrame); waitFrame.setVisible(true); return waitFrame; }
From source file:org.geopublishing.atlasViewer.swing.AtlasViewerGUI.java
/** * This is the {@link ActionListener} for the {@link JMenuItem}s and * {@link AtlasMenuItem}s//from w w w . j av a 2s .c o m */ @Override public void actionPerformed(ActionEvent evt) { final String cmd = evt.getActionCommand(); try { LOGGER.debug("evaluating ActionCommand string = " + cmd); if (cmd.startsWith(AtlasMenuItem.ACTIONCMD_MAPPOOL_PREFIX)) { // A new Map was selected // The MapID is in the ActionCommandString ( mappool123321 ) final String id = cmd.substring(AtlasMenuItem.ACTIONCMD_MAPPOOL_PREFIX.length()); Map map = getAtlasConfig().getMapPool().get(id); setMap(map); } else if (cmd.startsWith(AtlasMenuItem.ACTIONCMD_DATAPOOL_PREFIX)) { final String id = cmd.substring(AtlasMenuItem.ACTIONCMD_DATAPOOL_PREFIX.length()); final DpEntry<? extends ChartStyle> dpe = getAtlasConfig().getDataPool().get(id); if (!dpe.isLayer()) { LOGGER.debug("ActionCommand for a Media"); DpMedia media = (DpMedia) dpe; // getURL macht das sowieso media.seeJAR(getJFrame()); media.show(getJFrame()); } else { try { new AtlasSwingWorker<Boolean>(getJFrame()) { @Override protected Boolean doInBackground() throws Exception { // If there exist additional styles for this // layer, aktivate them all if (dpe instanceof DpLayerVectorFeatureSource) // Add all it's Charts to the Map by default: { DpLayerVectorFeatureSource dplvfs = (DpLayerVectorFeatureSource) dpe; // Activate all additional Styles if this // layer has never // been configured for this map final java.util.Map<String, ArrayList<String>> mapAadditionalStyles = getMap() .getAdditionalStyles(); if (mapAadditionalStyles.get(dplvfs.getId()) == null && dplvfs.getLayerStyles().size() > 0) { ArrayList<String> x = new ArrayList<String>(); for (LayerStyle ls : dplvfs.getLayerStyles()) { x.add(ls.getID()); } getMap().getAdditionalStyles().put(dplvfs.getId(), x); } } // Calling the mapView to add the Layer return getMapView().addStyledLayer((StyledLayerInterface<?>) dpe); } }.executeModal(); // } } catch (Throwable e) { ExceptionDialog.show(getJFrame(), e); } } } else if (cmd.equals("exit")) { exitAV(0); } else if (cmd.equals("about")) { /** * Opens a modal about window. */ JDialog aboutWindow = new AtlasAboutDialog(getJFrame(), true, getAtlasConfig()); aboutWindow.setVisible(true); } else if (cmd.equals("antiAliasing")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { boolean b = AtlasViewerGUI.this.getAtlasMenuBar().getJCheckBoxMenuItemAntiAliasing() .isSelected(); getAtlasConfig().getProperties().set(getJFrame(), AVProps.Keys.antialiasingMaps, b ? "1" : "0"); getMapView().getMapPane().setAntiAliasing(b); getMapView().getMapPane().repaint(); } }); } else { ExceptionDialog.show(getJFrame(), new AtlasRecoverableException( "A unknown ActionCommand was lost. ActionCommand was '" + cmd + "'")); } } catch (Throwable e) { LOGGER.error("error while performing ActionCommand '" + cmd + "'", e); ExceptionDialog.show(getJFrame(), e); } }
From source file:org.geworkbench.components.lincs.LincsInterface.java
private void viewLicense_actionPerformed(String FileName) { getLicenseFromFile(FileName);//w ww. j a va 2 s. c o m JDialog licenseDialog = new JDialog(); final JEditorPane jEditorPane = new JEditorPane("text/html", ""); jEditorPane.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); jEditorPane.setText(licenseContent); if (jEditorPane.getCaretPosition() > 1) { jEditorPane.setCaretPosition(1); } JScrollPane scrollPane = new JScrollPane(jEditorPane); licenseDialog.setTitle("Lincs Interface License"); licenseDialog.setContentPane(scrollPane); licenseDialog.setSize(400, 300); licenseDialog.setLocationRelativeTo(this); licenseDialog.setVisible(true); }