List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:Main.java
public static boolean showModalDialogOnEDT(JComponent contents, String title, String okButtonMessage, String cancelButtonMessage, ModalityType modalityType, final boolean systemExitOnDisposed) { class Result { boolean OK = false; }//www. j av a2s .com final Result result = new Result(); final JDialog dialog = new JDialog((Frame) null, title, true) { @Override public void dispose() { super.dispose(); if (systemExitOnDisposed) { System.exit(0); } } }; // ensure it doesn't block other dialogs if (modalityType != null) { dialog.setModalityType(modalityType); } // See http://stackoverflow.com/questions/1343542/how-do-i-close-a-jdialog-and-have-the-window-event-listeners-be-notified dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); if (okButtonMessage != null) { buttonPane.add(new JButton(new AbstractAction(okButtonMessage) { @Override public void actionPerformed(ActionEvent e) { result.OK = true; dialog.dispose(); } })); } if (cancelButtonMessage != null) { buttonPane.add(new JButton(new AbstractAction(cancelButtonMessage) { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } })); } JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BorderLayout()); panel.add(contents, BorderLayout.CENTER); panel.add(buttonPane, BorderLayout.SOUTH); // startup frame dialog.getContentPane().add(panel); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.pack(); // This hopefully centres the dialog even though the parameter is null // see http://stackoverflow.com/questions/213266/how-do-i-center-a-jdialog-on-screen dialog.setLocationRelativeTo(null); dialog.setVisible(true); return result.OK; }
From source file:fr.duminy.components.swing.form.JFormPane.java
/** * Display this form in a dialog.// w w w.j a va 2 s .c o m * * @param parentComponent The parent component of the dialog. * @return The final value entered by the user in the dialog, or null if it was cancelled. */ public B showDialog(Component parentComponent) { Window parentWindow; if (parentComponent == null) { parentWindow = JOptionPane.getRootFrame(); } else if (parentComponent instanceof Window) { parentWindow = (Window) parentComponent; } else { parentWindow = SwingUtilities.getWindowAncestor(parentComponent); } final JDialog dialog = new JDialog(parentWindow, title, Dialog.ModalityType.APPLICATION_MODAL); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setContentPane(this); dialog.setResizable(false); setBorder(null); final MutableObject<Boolean> validated = new MutableObject<>(false); FormListener<B> listener = new FormListener<B>() { @Override public void formValidated(Form<B> form) { validated.setValue(true); dialog.dispose(); } @Override public void formCancelled(Form<B> form) { dialog.dispose(); } }; try { addFormListener(listener); dialog.pack(); dialog.setVisible(true); return validated.getValue() ? getValue() : null; } finally { removeFormListener(listener); } }
From source file:de.codesourcery.gittimelapse.MyFrame.java
public MyFrame(File file, GitHelper gitHelper) throws RevisionSyntaxException, MissingObjectException, IncorrectObjectTypeException, AmbiguousObjectException, IOException, GitAPIException { super("GIT timelapse: " + file.getAbsolutePath()); if (gitHelper == null) { throw new IllegalArgumentException("gitHelper must not be NULL"); }//from w w w . java 2s . com this.gitHelper = gitHelper; this.file = file; this.diffPanel = new DiffPanel(); final JDialog dialog = new JDialog((Frame) null, "Please wait...", false); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add(new JLabel("Please wait, locating revisions..."), BorderLayout.CENTER); dialog.pack(); dialog.setVisible(true); final IProgressCallback callback = new IProgressCallback() { @Override public void foundCommit(ObjectId commitId) { System.out.println("*** Found commit " + commitId); } }; System.out.println("Locating commits..."); commitList = gitHelper.findCommits(file, callback); dialog.setVisible(false); if (commitList.isEmpty()) { throw new RuntimeException("Found no commits"); } setMenuBar(createMenuBar()); diffModeChooser.setModel(new DefaultComboBoxModel<MyFrame.DiffDisplayMode>(DiffDisplayMode.values())); diffModeChooser.setSelectedItem(DiffDisplayMode.ALIGN_CHANGES); diffModeChooser.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1); try { diffPanel.showRevision(commit); } catch (IOException | PatchApplyException e1) { e1.printStackTrace(); } } }); diffModeChooser.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); DiffDisplayMode mode = (DiffDisplayMode) value; switch (mode) { case ALIGN_CHANGES: setText("Align changes"); break; case REGULAR: setText("Regular"); break; default: setText(mode.toString()); } return result; } }); revisionSlider = new JSlider(1, commitList.size()); revisionSlider.setPaintLabels(true); revisionSlider.setPaintTicks(true); addKeyListener(keyListener); getContentPane().addKeyListener(keyListener); if (commitList.size() < 10) { revisionSlider.setMajorTickSpacing(1); revisionSlider.setMinorTickSpacing(1); } else { revisionSlider.setMajorTickSpacing(5); revisionSlider.setMinorTickSpacing(1); } final ObjectId latestCommit = commitList.getLatestCommit(); if (latestCommit != null) { revisionSlider.setValue(1 + commitList.indexOf(latestCommit)); revisionSlider.setToolTipText(latestCommit.getName()); } revisionSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (!revisionSlider.getValueIsAdjusting()) { final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1); long time = -System.currentTimeMillis(); try { diffPanel.showRevision(commit); } catch (IOException | PatchApplyException e1) { e1.printStackTrace(); } finally { time += System.currentTimeMillis(); } if (Main.DEBUG_MODE) { System.out.println("Rendering time: " + time); } } } }); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.gridx = 0; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.NONE; getContentPane().add(new JLabel("Diff display mode:"), cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 1; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.NONE; getContentPane().add(diffModeChooser, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 2; cnstrs.gridy = 0; cnstrs.gridwidth = 1; cnstrs.gridheight = 1; cnstrs.weightx = 1.0; cnstrs.weighty = 0; cnstrs.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(revisionSlider, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.gridx = 0; cnstrs.gridy = 1; cnstrs.gridwidth = 3; cnstrs.gridheight = 1; cnstrs.weightx = 1; cnstrs.weighty = 1; cnstrs.fill = GridBagConstraints.BOTH; getContentPane().add(diffPanel, cnstrs); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (latestCommit != null) { diffPanel.showRevision(latestCommit); } }
From source file:fll.subjective.SubjectiveFrame.java
/** * Show differences./*from w ww. j a v a 2 s . co m*/ */ private void showDifferencesDialog(final Collection<SubjectiveScoreDifference> diffs) { final SubjectiveDiffTableModel model = new SubjectiveDiffTableModel(diffs); final JTable table = new JTable(model); table.setGridColor(Color.BLACK); table.addMouseListener(new MouseAdapter() { public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 2) { final JTable target = (JTable) e.getSource(); final int row = target.getSelectedRow(); final SubjectiveScoreDifference diff = model.getDiffForRow(row); // find correct table final String category = diff.getCategory(); final JTable scoreTable = getTableForTitle(category); final int tabIndex = getTabIndexForCategory(category); getTabbedPane().setSelectedIndex(tabIndex); // get correct row and column final SubjectiveTableModel model = (SubjectiveTableModel) scoreTable.getModel(); final int scoreRow = model.getRowForTeamAndJudge(diff.getTeamNumber(), diff.getJudge()); final int scoreCol = model.getColForSubcategory(diff.getSubcategory()); if (scoreRow == -1 || scoreCol == -1) { throw new FLLRuntimeException( "Internal error: Cannot find correct row and column for score difference: " + diff); } scoreTable.changeSelection(scoreRow, scoreCol, false, false); } } }); final JDialog dialog = new JDialog(this, false); final Container cpane = dialog.getContentPane(); cpane.setLayout(new BorderLayout()); final JScrollPane tableScroller = new JScrollPane(table); cpane.add(tableScroller, BorderLayout.CENTER); dialog.pack(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); }
From source file:IHM.GialogGraph.java
public void Show() { VisualizationViewer<String, String> vv; vv = new VisualizationViewer<>(new CircleLayout<String, String>(JungGraph), dim); Transformer<String, String> transformer = new Transformer<String, String>() { @Override/* w w w.j a va2 s . c o m*/ public String transform(String arg0) { return arg0; } }; vv.getRenderContext().setVertexLabelTransformer(transformer); transformer = new Transformer<String, String>() { @Override public String transform(String arg0) { return arg0; } }; vv.getRenderContext().setEdgeLabelTransformer(transformer); vv.getRenderer().setVertexRenderer(new MyRenderer()); DefaultModalGraphMouse<String, Number> graphMouse = new DefaultModalGraphMouse<String, Number>(); vv.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); JDialog frame = new JDialog(MymainWidow); frame.getContentPane().add(vv); frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { MymainWidow.enable(); } @Override public void windowClosed(WindowEvent e) { MymainWidow.enable(); } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); frame.pack(); frame.setLocationRelativeTo(MymainWidow); frame.setResizable(true); frame.setVisible(true); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.standalone.StandaloneShutdownDialog.java
private void displayShutdownDialog() { String serverId = ServerDetector.getServerId(); log.info("Running in: " + (serverId != null ? serverId : "unknown server")); log.info("Console: " + ((System.console() != null) ? "available" : "not available")); log.info("Headless: " + (GraphicsEnvironment.isHeadless() ? "yes" : "no")); // Show this only when run from the standalone JAR via a double-click if (System.console() == null && !GraphicsEnvironment.isHeadless() && ServerDetector.isWinstone()) { log.info("If you are running WebAnno in a server environment, please use '-Djava.awt.headless=true'"); EventQueue.invokeLater(new Runnable() { @Override// w w w . j a v a2s . c o m public void run() { final JOptionPane optionPane = new JOptionPane(new JLabel( "<HTML>WebAnno is running now and can be accessed via <a href=\"http://localhost:8080\">http://localhost:8080</a>.<br>" + "WebAnno works best with the browsers Google Chrome or Safari.<br>" + "Use this dialog to shut WebAnno down.</HTML>"), JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_OPTION, null, new String[] { "Shutdown" }); final JDialog dialog = new JDialog((JFrame) null, "WebAnno", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { // Avoid closing window by other means than button } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent aEvt) { if (dialog.isVisible() && (aEvt.getSource() == optionPane) && (aEvt.getPropertyName().equals(JOptionPane.VALUE_PROPERTY))) { System.exit(0); } } }); dialog.pack(); dialog.setVisible(true); } }); } else { log.info("Running in server environment or from command line: disabling interactive shutdown dialog."); } }
From source file:es.emergya.ui.plugins.admin.AdminLayers.java
protected SummaryAction getSummaryAction(final CapaInformacion capaInformacion) { SummaryAction action = new SummaryAction(capaInformacion) { private static final long serialVersionUID = -3691171434904452485L; @Override//from w w w .j av a2 s .co m protected JFrame getSummaryDialog() { if (capaInformacion != null) { d = getDialog(capaInformacion, null, "", null, "image/png"); return d; } else { JDialog primera = getJDialog(); primera.setResizable(false); primera.setVisible(true); primera.setAlwaysOnTop(true); } return null; } private JDialog getJDialog() { final JDialog dialog = new JDialog(); dialog.setTitle(i18n.getString("admin.capas.nueva.titleBar")); dialog.setIconImage(getBasicWindow().getIconImage()); dialog.setLayout(new BorderLayout()); JPanel centro = new JPanel(new FlowLayout()); centro.setOpaque(false); JLabel label = new JLabel(i18n.getString("admin.capas.nueva.url")); final JTextField url = new JTextField(50); final JLabel icono = new JLabel(LogicConstants.getIcon("48x48_transparente")); label.setLabelFor(url); centro.add(label); centro.add(url); centro.add(icono); dialog.add(centro, BorderLayout.CENTER); JPanel pie = new JPanel(new FlowLayout(FlowLayout.TRAILING)); pie.setOpaque(false); final JButton siguiente = new JButton(i18n.getString("admin.capas.nueva.boton.siguiente"), LogicConstants.getIcon("button_next")); JButton cancelar = new JButton(i18n.getString("admin.capas.nueva.boton.cancelar"), LogicConstants.getIcon("button_cancel")); final SiguienteActionListener siguienteActionListener = new SiguienteActionListener(url, dialog, icono, siguiente); url.addActionListener(siguienteActionListener); siguiente.addActionListener(siguienteActionListener); cancelar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); pie.add(siguiente); pie.add(cancelar); dialog.add(pie, BorderLayout.SOUTH); dialog.getContentPane().setBackground(Color.WHITE); dialog.pack(); dialog.setLocationRelativeTo(null); return dialog; } private JFrame getDialog(final CapaInformacion c, final Capa[] left_items, final String service, final Map<String, Boolean> transparentes, final String png) { if (left_items != null && left_items.length == 0) { JOptionPane.showMessageDialog(AdminLayers.this, i18n.getString("admin.capas.nueva.error.noCapasEnServicio")); } else { final String label_cabecera = i18n.getString("admin.capas.nueva.nombreCapa"); final String label_pie = i18n.getString("admin.capas.nueva.infoAdicional"); final String centered_label = i18n.getString("admin.capas.nueva.origenDatos"); final String left_label = i18n.getString("admin.capas.nueva.subcapasDisponibles"); final String right_label; if (left_items != null) { right_label = i18n.getString("admin.capas.nueva.capasSeleccionadas"); } else { right_label = i18n.getString("admin.capas.ficha.capasSeleccionadas"); } final String tituloVentana, cabecera; if (c.getNombre() == null) { tituloVentana = i18n.getString("admin.capas.nueva.titulo.nuevaCapa"); cabecera = i18n.getString("admin.capas.nueva.cabecera.nuevaCapa"); } else { tituloVentana = i18n.getString("admin.capas.nueva.titulo.ficha"); cabecera = i18n.getString("admin.capas.nueva.cabecera.ficha"); } final Capa[] right_items = c.getCapas().toArray(new Capa[0]); final AdminPanel.SaveOrUpdateAction<CapaInformacion> guardar = layers.new SaveOrUpdateAction<CapaInformacion>( c) { private static final long serialVersionUID = 7447770296943341404L; @Override public void actionPerformed(ActionEvent e) { if (isNew && CapaConsultas.alreadyExists(textfieldCabecera.getText())) { JOptionPane.showMessageDialog(super.frame, i18n.getString("admin.capas.nueva.error.nombreCapaYaExiste")); } else if (textfieldCabecera.getText().isEmpty()) { JOptionPane.showMessageDialog(super.frame, i18n.getString("admin.capas.nueva.error.nombreCapaEnBlanco")); } else if (((DefaultListModel) right.getModel()).size() == 0) { JOptionPane.showMessageDialog(super.frame, i18n.getString("admin.capas.nueva.error.noCapasSeleccionadas")); } else if (cambios) { int i = JOptionPane.showConfirmDialog(super.frame, i18n.getString("admin.capas.nueva.confirmar.guardar.titulo"), i18n.getString("admin.capas.nueva.confirmar.boton.guardar"), JOptionPane.YES_NO_CANCEL_OPTION); if (i == JOptionPane.YES_OPTION) { if (original == null) { original = new CapaInformacion(); } original.setInfoAdicional(textfieldPie.getText()); original.setNombre(textfieldCabecera.getText()); original.setHabilitada(habilitado.isSelected()); original.setOpcional(comboTipoCapa.getSelectedIndex() != 0); boolean transparente = true; HashSet<Capa> capas = new HashSet<Capa>(); List<Capa> capasEnOrdenSeleccionado = new ArrayList<Capa>(); int indice = 0; for (Object c : ((DefaultListModel) right.getModel()).toArray()) { if (c instanceof Capa) { transparente = transparente && (transparentes != null && transparentes.get(((Capa) c).getNombre()) != null && transparentes.get(((Capa) c).getNombre())); capas.add((Capa) c); capasEnOrdenSeleccionado.add((Capa) c); ((Capa) c).setCapaInformacion(original); ((Capa) c).setOrden(indice++); // ((Capa) // c).setNombre(c.toString()); } } original.setCapas(capas); if (original.getId() == null) { String url = nombre.getText(); if (url.indexOf("?") > -1) { if (!url.endsWith("?")) { url += "&"; } } else { url += "?"; } url += "VERSION=" + version + "&REQUEST=GetMap&FORMAT=" + png + "&SERVICE=" + service + "&WIDTH={2}&HEIGHT={3}&BBOX={1}&SRS={0}"; // if (transparente) url += "&TRANSPARENT=TRUE"; url += "&LAYERS="; String estilos = ""; final String coma = "%2C"; if (capasEnOrdenSeleccionado.size() > 0) { for (Capa c : capasEnOrdenSeleccionado) { url += c.getTitulo().replaceAll(" ", "+") + coma; estilos += c.getEstilo() + coma; } estilos = estilos.substring(0, estilos.length() - coma.length()); estilos = estilos.replaceAll(" ", "+"); url = url.substring(0, url.length() - coma.length()); } url += "&STYLES=" + estilos; original.setUrl_visible(original.getUrl()); original.setUrl(url); } CapaInformacionAdmin.saveOrUpdate(original); cambios = false; layers.setTableData(getAll(new CapaInformacion())); closeFrame(); } else if (i == JOptionPane.NO_OPTION) { closeFrame(); } } else { closeFrame(); } } }; JFrame segunda = generateUrlDialog(label_cabecera, label_pie, centered_label, tituloVentana, left_items, right_items, left_label, right_label, guardar, LogicConstants.getIcon("tittleficha_icon_capa"), cabecera, c.getHabilitada(), c.getOpcional(), c.getUrl_visible()); segunda.setResizable(false); if (c != null) { textfieldCabecera.setText(c.getNombre()); textfieldPie.setText(c.getInfoAdicional()); nombre.setText(c.getUrl_visible()); nombre.setEditable(false); if (c.getHabilitada() == null) { c.setHabilitada(false); } habilitado.setSelected(c.getHabilitada()); if (c.isOpcional() != null && c.isOpcional()) { comboTipoCapa.setSelectedIndex(1); } else { comboTipoCapa.setSelectedIndex(0); } } if (c.getId() == null) { habilitado.setSelected(true); comboTipoCapa.setSelectedIndex(1); } habilitado.setEnabled(true); if (c == null || c.getId() == null) { textfieldCabecera.setEditable(true); } else { textfieldCabecera.setEditable(false); } cambios = false; segunda.pack(); segunda.setLocationRelativeTo(null); segunda.setVisible(true); return segunda; } return null; } class SiguienteActionListener implements ActionListener { private final JTextField url; private final JDialog dialog; private final JLabel icono; private final JButton siguiente; public SiguienteActionListener(JTextField url, JDialog dialog, JLabel icono, JButton siguiente) { this.url = url; this.dialog = dialog; this.icono = icono; this.siguiente = siguiente; } @Override public void actionPerformed(ActionEvent e) { final CapaInformacion ci = new CapaInformacion(); ci.setUrl(url.getText()); ci.setCapas(new HashSet<Capa>()); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { private List<Capa> res = new LinkedList<Capa>(); private String service = "WMS"; private String png = null; private Map<String, Boolean> transparentes = new HashMap<String, Boolean>(); private ArrayList<String> errorStack = new ArrayList<String>(); private Boolean goOn = true; @SuppressWarnings(value = "unchecked") @Override protected Object doInBackground() throws Exception { try { final String url2 = ci.getUrl(); WMSClient client = new WMSClient(url2); client.connect(new ICancellable() { @Override public boolean isCanceled() { return false; } @Override public Object getID() { return System.currentTimeMillis(); } }); version = client.getVersion(); for (final String s : client.getLayerNames()) { WMSLayer layer = client.getLayer(s); // this.service = // client.getServiceName(); final Vector allSrs = layer.getAllSrs(); boolean epsg = (allSrs != null) ? allSrs.contains("EPSG:4326") : false; final Vector formats = client.getFormats(); if (formats.contains("image/png")) { png = "image/png"; } else if (formats.contains("IMAGE/PNG")) { png = "IMAGE/PNG"; } else if (formats.contains("png")) { png = "png"; } else if (formats.contains("PNG")) { png = "PNG"; } boolean image = png != null; if (png == null) { png = "IMAGE/PNG"; } if (epsg && image) { boolean hasTransparency = layer.hasTransparency(); this.transparentes.put(s, hasTransparency); Capa capa = new Capa(); capa.setCapaInformacion(ci); if (layer.getStyles().size() > 0) { capa.setEstilo(((WMSStyle) layer.getStyles().get(0)).getName()); } capa.setNombre(layer.getTitle()); capa.setTitulo(s); res.add(capa); if (!hasTransparency) { errorStack.add(i18n.getString(Locale.ROOT, "admin.capas.nueva.error.capaNoTransparente", layer.getTitle())); } } else { String error = ""; // if (opaque) // error += "<li>Es opaca</li>"; if (!image) { error += i18n.getString("admin.capas.nueva.error.formatoPNG"); } if (!epsg) { error += i18n.getString("admin.capas.nueva.error.projeccion"); } final String cadena = i18n.getString(Locale.ROOT, "admin.capas.nueva.error.errorCapa", new Object[] { s, error }); errorStack.add(cadena); } } } catch (final Throwable t) { log.error("Error al parsear el WMS", t); goOn = false; icono.setIcon(LogicConstants.getIcon("48x48_transparente")); JOptionPane.showMessageDialog(dialog, i18n.getString("admin.capas.nueva.error.errorParseoWMS")); siguiente.setEnabled(true); } return null; } @Override protected void done() { super.done(); if (goOn) { dialog.dispose(); ci.setUrl_visible(ci.getUrl()); final JFrame frame = getDialog(ci, res.toArray(new Capa[0]), service, transparentes, png); if (!errorStack.isEmpty()) { String error = "<html>"; for (final String s : errorStack) { error += s + "<br/>"; } error += "</html>"; final String errorString = error; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(frame, errorString); } }); } } } }; sw.execute(); icono.setIcon(LogicConstants.getIcon("anim_conectando")); icono.repaint(); siguiente.setEnabled(false); } } }; return action; }
From source file:fll.subjective.SubjectiveFrame.java
/** * Make sure the data in the table is valid. This checks to make sure that for * all rows, all columns that contain numeric data are actually set, or none * of these columns are set in a row. This avoids the case of partial data. * This method is fail fast in that it will display a dialog box on the first * error it finds.//from ww w . j av a2 s . com * * @return true if everything is ok */ @SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC_ANON", justification = "Static inner class to replace anonomous listener isn't worth the confusion of finding the class definition") private boolean validateData() { stopCellEditors(); final List<String> warnings = new LinkedList<String>(); for (final ScoreCategory subjectiveCategory : getChallengeDescription().getSubjectiveCategories()) { final String category = subjectiveCategory.getName(); final String categoryTitle = subjectiveCategory.getTitle(); final List<AbstractGoal> goals = subjectiveCategory.getGoals(); final List<Element> scoreElements = SubjectiveTableModel.getScoreElements(_scoreDocument, category); for (final Element scoreElement : scoreElements) { int numValues = 0; for (final AbstractGoal goal : goals) { final String goalName = goal.getName(); final Element subEle = SubjectiveUtils.getSubscoreElement(scoreElement, goalName); if (null != subEle) { final String value = subEle.getAttribute("value"); if (!value.isEmpty()) { numValues++; } } } if (numValues != goals.size() && numValues != 0) { warnings.add(categoryTitle + ": " + scoreElement.getAttribute("teamNumber") + " has too few scores (needs all or none): " + numValues); } } } if (!warnings.isEmpty()) { // join the warnings with carriage returns and display them final StyledDocument doc = new DefaultStyledDocument(); for (final String warning : warnings) { try { doc.insertString(doc.getLength(), warning + "\n", null); } catch (final BadLocationException ble) { throw new RuntimeException(ble); } } final JDialog dialog = new JDialog(this, "Warnings"); final Container cpane = dialog.getContentPane(); cpane.setLayout(new BorderLayout()); final JButton okButton = new JButton("Ok"); cpane.add(okButton, BorderLayout.SOUTH); okButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent ae) { dialog.setVisible(false); dialog.dispose(); } }); cpane.add(new JTextPane(doc), BorderLayout.CENTER); dialog.pack(); dialog.setVisible(true); return false; } else { return true; } }
From source file:net.sourceforge.processdash.ev.ui.ScheduleBalancingDialog.java
private void buildAndShowGUI() { chartData = null;/*from w w w. j a va 2 s. co m*/ int numScheduleRows = scheduleRows.size(); sumUpTotalTime(); originalTotalTime = totalRow.time; if (originalTotalTime == 0) // if the rows added up to zero, choose a nominal target total time // corresponding to 10 hours per included schedule originalTotalTime = numScheduleRows * 60 * 10; JPanel panel = new JPanel(new GridBagLayout()); if (numScheduleRows == 1) { totalRow.rowLabel = scheduleRows.get(0).rowLabel; } else { for (int i = 0; i < numScheduleRows; i++) scheduleRows.get(i).addToPanel(panel, i); scheduleRows.get(numScheduleRows - 1).showPercentageTickMarks(); addChartToPanel(panel, numScheduleRows + 1); } totalRow.addToPanel(panel, numScheduleRows); if (rowsAreEditable == false) { String title = TaskScheduleDialog.resources.getString("Balance.Read_Only_Title"); JOptionPane.showMessageDialog(parent.frame, panel, title, JOptionPane.PLAIN_MESSAGE); } else { String title = TaskScheduleDialog.resources.getString("Balance.Editable_Title"); JDialog dialog = new JDialog(parent.frame, title, true); addButtons(dialog, panel, numScheduleRows + 2); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); dialog.getContentPane().add(panel); dialog.pack(); dialog.setLocationRelativeTo(parent.frame); dialog.setResizable(true); dialog.setVisible(true); } }
From source file:fxts.stations.transport.tradingapi.TradingServerSession.java
public void relogin() { if (mLogout) { return;// ww w . j a v a 2 s . c o m } final JDialog jd = TradeApp.getInst().getMainFrame().createWaitDialog("Session Lost...Reconnecting"); jd.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent aEvent) { Thread worker = new Thread(new Runnable() { public void run() { try { TradingServerSession.getInstance().getGateway().relogin(); Liaison.getInstance().refresh(); } catch (Exception e) { e.printStackTrace(); } finally { jd.dispose(); jd.setVisible(false); } } }); worker.start(); } }); jd.setVisible(true); }