List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:com.diversityarrays.update.UpdateDialog.java
private void checkForUpdates(PrintStream ps) { StringBuilder sb = new StringBuilder(updateCheckRequest.updateBaseUrl); sb.append(updateCheckRequest.versionCode); if (RunMode.getRunMode().isDeveloper()) { sb.append("-dev"); //$NON-NLS-1$ }//from ww w . j av a2 s . c o m sb.append(".json"); //$NON-NLS-1$ final String updateUrl; updateUrl = sb.toString(); // updateUrl = "NONEXISTENT"; // Uncomment to check error final ProgressMonitor progressMonitor = new ProgressMonitor(updateCheckRequest.owner, Msg.PROGRESS_CHECKING(), null, 0, 0); worker = new SwingWorker<String, Void>() { @Override protected String doInBackground() throws Exception { // Thread.sleep(3000); // Uncomment to check delay BufferedReader reader = null; StringBuffer buffer = new StringBuffer(); try { URL url = new URL(updateUrl); reader = new BufferedReader(new InputStreamReader(url.openStream())); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) { if (progressMonitor.isCanceled()) { cancel(true); return null; } buffer.append(chars, 0, read); } } catch (IOException e) { System.err.println("checkForUpdates: " + e.getMessage()); //$NON-NLS-1$ } finally { if (reader != null) { reader.close(); } } return buffer.toString(); } @Override protected void done() { try { String json = get(); Gson gson = new Gson(); setKDXploreUpdate(gson.fromJson(json, KDXploreUpdate.class)); } catch (CancellationException ignore) { } catch (InterruptedException ignore) { } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof UnknownHostException) { String site = extractSite(updateUrl); ps.println(Msg.ERRMSG_UNABLE_TO_CONTACT_UPDATE_SITE(site)); } else { cause.printStackTrace(ps); } if (cause instanceof FileNotFoundException) { FileNotFoundException fnf = (FileNotFoundException) cause; if (updateUrl.equals(fnf.getMessage())) { // Well maybe someone forgot to create the file on // the server! System.err.println("Maybe someone forgot to create the file!"); //$NON-NLS-1$ System.err.println(fnf.getMessage()); setKDXploreUpdate(new KDXploreUpdate(Msg.ERRMSG_PROBLEMS_CONTACTING_UPDATE_SERVER_1())); return; } } String msg = Msg.HTML_PROBLEMS_CONTACTING_UPDATE_2(StringUtil.htmlEscape(updateUrl), cause.getClass().getSimpleName(), StringUtil.htmlEscape(cause.getMessage())); kdxploreUpdate = new KDXploreUpdate(msg); kdxploreUpdate.unknownHost = (cause instanceof UnknownHostException); return; } } private String extractSite(final String updateUrl) { String site = null; int spos = updateUrl.indexOf("://"); if (spos > 0) { int epos = updateUrl.indexOf('/', spos + 1); if (epos > 0) { site = updateUrl.substring(0, epos); } } if (site == null) { site = updateUrl; } return site; } }; Closure<JDialog> onComplete = new Closure<JDialog>() { @Override public void execute(JDialog d) { if (!processReadUrlResult(updateUrl)) { d.dispose(); } else { d.setVisible(true); } } }; SwingWorkerCompletionWaiter waiter = new SwingWorkerCompletionWaiter(this, onComplete); worker.addPropertyChangeListener(waiter); worker.execute(); }
From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java
/** * Callback method for receiving notification of a mouse click on a chart. * * @param event information about the event. *//*from ww w.j a va 2 s . c om*/ public void chartMouseClicked(ChartMouseEvent event) { if (event.getTrigger().getClickCount() > 1) { if (event.getEntity() instanceof XYItemEntity) { XYItemEntity item = (XYItemEntity) event.getEntity(); Component c = event.getTrigger().getComponent(); final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false); dialog.setSize(400, 300); dialog.setLocation(getDialogLocation(dialog, c)); dialog.add(getItemPanel(dialog, item, event)); dialog.setVisible(true); } else { XYItemEntity item = (XYItemEntity) event.getEntity(); Component c = event.getTrigger().getComponent(); final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false); dialog.setSize(400, 300); dialog.setLocation(getDialogLocation(dialog, c)); dialog.add(getSeriesPanel(dialog, event)); dialog.setVisible(true); } } else { if (!(event.getChart().getXYPlot().getRenderer() instanceof MotionBubbleRenderer)) { return; } MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); if (event.getEntity() instanceof XYItemEntity) { boolean selected; XYItemEntity entity = (XYItemEntity) event.getEntity(); int series = entity.getSeriesIndex(); int item = entity.getItem(); Object category = dataset.getCategory(series, item); if (category == null) { selected = !renderer.isSelectedItem(series, item); renderer.setSelectedItem(series, item, selected); } else { selected = !renderer.isSelectedCategory(category); renderer.setSelectedCategory(category, selected); } } } }
From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java
protected JPanel getPanel(final JDialog dialog, DefaultTableModel tModel, ArrayList<String> rowIdentifiers) { JPanel panel = new JPanel(); JButton close = new JButton("Close"); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); }/*from w w w .j a v a 2 s. c om*/ }); close.setAlignmentX(Component.CENTER_ALIGNMENT); RowHeaderTable table = new RowHeaderTable(tModel); table.getDataTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getDataTable().setDefaultRenderer(Object.class, new ColorRenderer(false)); table.setCellsEditable(false); table.setHeadersEditable(false); for (int r = 0; r < tModel.getRowCount() && rowIdentifiers.size() <= tModel.getRowCount(); r++) { table.getRowHeaderModel().setValueAt(rowIdentifiers.get(r), r, 0); } Dimension d = table.getRowHeaderTable().getPreferredScrollableViewportSize(); d.width = 55; table.getRowHeaderTable().setPreferredScrollableViewportSize(d); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.add(table); panel.add(Box.createRigidArea(new Dimension(0, 5))); panel.add(close); return panel; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java
/** * Creates a dialog window which contains the chart in its preferred size. *///from www . j av a2 s. c om private void displayEnlarged() { JDialog dialog = new JDialog(ownerDialog, visualizer.getTitle(), false); dialog.getContentPane().add(JFreeChartConn.createPanel(chart)); dialog.pack(); dialog.setLocationRelativeTo(ownerDialog); dialog.setVisible(true); }
From source file:Installer.java
public static JLabel linkify(final String text, String URL, String toolTip) { URI temp = null;/*from www. j a va2 s . c om*/ try { temp = new URI(URL); } catch (Exception e) { e.printStackTrace(); } final URI uri = temp; final JLabel link = new JLabel(); link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); if (!toolTip.equals("")) link.setToolTipText(toolTip); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.addMouseListener(new MouseListener() { public void mouseExited(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); } public void mouseEntered(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\"><U>" + text + "</U></FONT></HTML>"); } public void mouseClicked(MouseEvent arg0) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(uri); } catch (Exception e) { e.printStackTrace(); } } else { JOptionPane pane = new JOptionPane("Could not open link."); JDialog dialog = pane.createDialog(new JFrame(), ""); dialog.setVisible(true); } } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); return link; }
From source file:eu.asterics.mw.services.AstericsErrorHandling.java
/** * This method is used by the components to report an error. It logs the error in "warning" logger * and sets the status of the ARE to "ERROR" to denote that an error has occurred * @param component the component instance that reports the error * @param errorMsg the error message// w ww.jav a2 s .c o m */ public void reportError(IRuntimeComponentInstance component, final String errorMsg) { if (component != null) { String componentID = DeploymentManager.instance .getIRuntimeComponentInstanceIDFromIRuntimeComponentInstance(component); if (componentID != null) { //System.out.println("componentID: "+componentID); logger.warning(componentID + ": " + errorMsg); setStatusObject(AREStatus.ERROR.toString(), componentID, errorMsg); } } AREProperties props = AREProperties.instance; if (props.checkProperty("showErrorDialogs", "1")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ErrorLogPane.appendLog(errorMsg); DeploymentManager.instance.setStatus(AREStatus.ERROR); AstericsErrorHandling.this.notifyAREEventListeners("onAreError", errorMsg); JOptionPane op = new JOptionPane(errorMsg, JOptionPane.WARNING_MESSAGE); JDialog dialog = op.createDialog("AsTeRICS Runtime Environment:"); dialog.setAlwaysOnTop(true); dialog.setModal(false); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } }); } }
From source file:org.nekorp.workflow.desktop.view.quick.ServicioPreview.java
private void historialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_historialActionPerformed this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); javax.swing.JDialog dialog = historialServicioDialogFactory.createDialog(null, true); this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); dialog.setVisible(true); }
From source file:org.martus.client.swingui.FxInSwingMainWindow.java
protected void initializationErrorExitMartusDlg(String message) { String title = "Error Starting Martus"; String cause = "Unable to start Martus: \n" + message; String ok = "OK"; String[] buttons = { ok };/* ww w . j a v a2s. c om*/ UiOptionPane pane = new UiOptionPane(cause, UiOptionPane.INFORMATION_MESSAGE, UiOptionPane.DEFAULT_OPTION, null, buttons); JDialog dialog = pane.createDialog(null, title); dialog.setVisible(true); System.exit(1); }
From source file:com.floreantpos.config.ui.TerminalConfigurationView.java
public void restartPOS() { JOptionPane optionPane = new JOptionPane(Messages.getString("TerminalConfigurationView.26"), //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, Application.getApplicationIcon(), new String[] { /*Messages.getString("TerminalConfigurationView.28"),*/Messages .getString("TerminalConfigurationView.30") }); //$NON-NLS-1$ //$NON-NLS-2$ Object[] optionValues = optionPane.getComponents(); for (Object object : optionValues) { if (object instanceof JPanel) { JPanel panel = (JPanel) object; Component[] components = panel.getComponents(); for (Component component : components) { if (component instanceof JButton) { component.setPreferredSize(new Dimension(100, 80)); JButton button = (JButton) component; button.setPreferredSize(PosUIManager.getSize(100, 50)); }/*w ww . j a v a 2 s . c o m*/ } } } JDialog dialog = optionPane.createDialog(Application.getPosWindow(), Messages.getString("TerminalConfigurationView.31")); //$NON-NLS-1$ dialog.setIconImage(Application.getApplicationIcon().getImage()); dialog.setLocationRelativeTo(Application.getPosWindow()); dialog.setVisible(true); Object selectedValue = (String) optionPane.getValue(); if (selectedValue != null) { if (selectedValue.equals(Messages.getString("TerminalConfigurationView.28"))) { //$NON-NLS-1$ try { Main.restart(); } catch (IOException | InterruptedException | URISyntaxException e) { } } else { } } }
From source file:com.ln.gui.Main.java
public void swingupd() { EventQueue.invokeLater(new Runnable() { public void run() { try { String av = "Updates available!"; JOptionPane pane1 = new JOptionPane(av, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); Updatechecker upd = new Updatechecker(); upd.setVisible(true);/*from w w w. j av a 2s . com*/ upd.setLocationRelativeTo(rootPane); upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } catch (Exception e) { } } }); }