List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:nick.gaImageRecognitionGui.panel.JPanelTraining.java
private void jButtonTrainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTrainActionPerformed IApiTrainer trainer = initTrainer(); saveSettings();//from w w w . j a va2s .c om JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); final JDialog frame = new JDialog(topFrame, false); JPanelTrainingInProgress trainingPanel = new JPanelTrainingInProgress(trainer); frame.getContentPane().add(trainingPanel); frame.pack(); Util.centreWindow(frame); frame.setVisible(true); }
From source file:nick.gaImageRecognitionGui.panel.JPanelTraining.java
private void jButtonSetTrainingRulesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSetTrainingRulesActionPerformed JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); final JDialog frame = new JDialog(topFrame, true); JPanelSetTrainingRules setTrainingrules = new JPanelSetTrainingRules(trainingRules); frame.getContentPane().add(setTrainingrules); frame.pack();/*from w w w. j av a 2 s .co m*/ Util.centreWindow(frame); frame.setVisible(true); }
From source file:nz.ac.massey.cs.gql4jung.browser.queryviews.GraphBasedQueryView.java
public static void show(JFrame parent, Motif motif, String title) { JDialog dlg = new JDialog(parent, title, false); GraphBasedQueryView qv = new GraphBasedQueryView(); qv.display(motif, null);/*from w w w. j a v a 2 s.co m*/ dlg.add(qv); dlg.setTitle(title); dlg.setSize(900, 600); dlg.setLocation(100, 100); dlg.setVisible(true); }
From source file:ome.formats.importer.gui.FileQueueHandler.java
/** * Retrieve the file chooser's selected reader then iterate over * each of our supplied containers filtering out those whose format * do not match those of the selected reader. * //from w w w . ja v a 2 s .com * @param allContainers List of ImporterContainers */ private void handleFiles(List<ImportContainer> allContainers) { FileFilter selectedFilter = fileChooser.getFileFilter(); IFormatReader selectedReader = null; if (selectedFilter instanceof FormatFileFilter) { log.debug("Selected file filter: " + selectedFilter); selectedReader = ((FormatFileFilter) selectedFilter).getReader(); } List<ImportContainer> containers = new ArrayList<ImportContainer>(); for (ImportContainer ic : allContainers) { if (selectedReader == null) { // The user selected "All supported file types" containers = allContainers; break; } String a = selectedReader.getFormat(); String b = ic.getReader(); if (a.equals(b) || b == null) { containers.add(ic); } else { log.debug(String.format("Skipping %s (%s != %s)", ic.getFile().getAbsoluteFile(), a, b)); } } Boolean spw = spwOrNull(containers); if (containers.size() == 0 && !candidatesFormatException) { final JOptionPane optionPane = new JOptionPane("\nNo importable files found in this selection.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(viewer, "No Importable Files Found", true); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(viewer); errorDialog.setVisible(true); } if (candidatesFormatException) { viewer.candidateErrorsCollected(viewer); candidatesFormatException = false; } if (spw == null) { addEnabled(true); containers.clear(); return; // Invalid containers. } if (getOMEROMetadataStoreClient() != null && spw.booleanValue()) { addEnabled(true); SPWDialog dialog = new SPWDialog(config, viewer, "Screen Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.screen == null) return; for (ImportContainer ic : containers) { ic.setTarget(dialog.screen); String title = dialog.screen.getName().getValue(); addFileToQueue(ic, title, false, 0); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else if (getOMEROMetadataStoreClient() != null) { addEnabled(true); ImportDialog dialog = new ImportDialog(config, viewer, "Image Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.dataset == null) return; Double[] pixelSizes = new Double[] { dialog.pixelSizeX, dialog.pixelSizeY, dialog.pixelSizeZ }; Boolean useFullPath = config.useFullPath.get(); if (dialog.useCustomNamingChkBox.isSelected() == false) useFullPath = null; //use the default bio-formats naming for (ImportContainer ic : containers) { ic.setTarget(dialog.dataset); ic.setUserPixels(pixelSizes); ic.setArchive(dialog.archiveImage.isSelected()); String title = ""; if (dialog.project.getId() != null) { ic.setProjectID(dialog.project.getId().getValue()); title = dialog.project.getName().getValue() + " / " + dialog.dataset.getName().getValue(); } else { title = "none / " + dialog.dataset.getName().getValue(); } addFileToQueue(ic, title, useFullPath, config.numOfDirectories.get()); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else { addEnabled(true); JOptionPane.showMessageDialog(viewer, "Due to an error the application is unable to \n" + "retrieve an OMEROMetadataStore and cannot continue." + "The most likely cause for this error is that you" + "are not logged in. Please try to login again."); } }
From source file:ome.formats.importer.gui.GuiImporter.java
public void update(IObservable importLibrary, ImportEvent event) { // Keep alive has failed, call logout if (event instanceof ImportEvent.LOGGED_OUT) { logout();/*from w w w. jav a 2s .co m*/ showLogoutMessage(); } if (event instanceof ImportEvent.LOADING_IMAGE) { ImportEvent.LOADING_IMAGE ev = (ImportEvent.LOADING_IMAGE) event; getStatusBar().setProgress(true, -1, "Loading file " + ev.numDone + " of " + ev.total); appendToOutput("> [" + ev.index + "] Loading image \"" + ev.shortName + "\"...\n"); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Prepping file \"" + ev.shortName); } else if (event instanceof ImportEvent.LOADED_IMAGE) { ImportEvent.LOADED_IMAGE ev = (ImportEvent.LOADED_IMAGE) event; getStatusBar().setProgress(true, -1, "Analyzing file " + ev.numDone + " of " + ev.total); appendToOutput(" Succesfully loaded.\n"); appendToOutput("> [" + ev.index + "] Importing metadata for " + "image \"" + ev.shortName + "\"... "); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Analyzing the metadata for file \"" + ev.shortName); } else if (event instanceof ImportEvent.BEGIN_SAVE_TO_DB) { ImportEvent.BEGIN_SAVE_TO_DB ev = (ImportEvent.BEGIN_SAVE_TO_DB) event; appendToOutput("> [" + ev.index + "] Saving metadata for " + "image \"" + ev.filename + "\"... "); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Saving metadata for file \"" + ev.filename); } else if (event instanceof ImportEvent.DATASET_STORED) { ImportEvent.DATASET_STORED ev = (ImportEvent.DATASET_STORED) event; int num = ev.numDone; int tot = ev.total; int pro = num - 1; appendToOutputLn("Successfully stored to " + ev.target.getClass().getSimpleName() + " \"" + ev.filename + "\" with id \"" + ev.target.getId().getValue() + "\"."); appendToOutputLn( "> [" + ev.series + "] Importing pixel data for " + "image \"" + ev.filename + "\"... "); getStatusBar().setProgress(true, 0, "Importing file " + num + " of " + tot); getStatusBar().setProgressValue(pro); getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Importing the pixel data for file \"" + ev.filename); appendToOutput("> Importing plane: "); } else if (event instanceof ImportEvent.DATA_STORED) { ImportEvent.DATA_STORED ev = (ImportEvent.DATA_STORED) event; appendToOutputLn("> Successfully stored with pixels id \"" + ev.pixId + "\"."); appendToOutputLn("> [" + ev.filename + "] Image imported successfully!"); } else if (event instanceof FILE_EXCEPTION) { FILE_EXCEPTION ev = (FILE_EXCEPTION) event; if (IOException.class.isAssignableFrom(ev.exception.getClass())) { final JOptionPane optionPane = new JOptionPane( "The importer cannot retrieve one of your images in a timely manner.\n" + "The file in question is:\n'" + ev.filename + "'\n\n" + "There are a number of reasons you may see this error:\n" + " - The file has been deleted.\n" + " - There was a networking error retrieving a remotely saved file.\n" + " - An archived file has not been fully retrieved from backup.\n\n" + "The importer should now continue with the remainer of your imports.\n", JOptionPane.ERROR_MESSAGE); final JDialog dialog = new JDialog(this, "IO Error"); dialog.setAlwaysOnTop(true); dialog.setContentPane(optionPane); dialog.pack(); dialog.setVisible(true); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { dialog.dispose(); } } }); } } else if (event instanceof EXCEPTION_EVENT) { EXCEPTION_EVENT ev = (EXCEPTION_EVENT) event; log.error("EXCEPTION_EVENT", ev.exception); } else if (event instanceof INTERNAL_EXCEPTION) { INTERNAL_EXCEPTION e = (INTERNAL_EXCEPTION) event; log.error("INTERNAL_EXCEPTION", e.exception); // What else should we do here? Why are EXCEPTION_EVENTs being // handled here? } else if (event instanceof ImportEvent.ERRORS_PENDING) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON_ANIM)); errors_pending = true; error_notification = true; } else if (event instanceof ImportEvent.ERRORS_COMPLETE) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON)); error_notification = false; } else if (event instanceof ImportEvent.ERRORS_COMPLETE) { tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON)); error_notification = false; } else if (event instanceof ImportEvent.ERRORS_FAILED) { sendingErrorsFailed(this); } else if (event instanceof ImportEvent.IMPORT_QUEUE_DONE && errors_pending == true) { errors_pending = false; importErrorsCollected(this); } }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display errors in import dialog //from w w w. ja va2 s .com * * @param frame - parent frame */ private void importErrorsCollected(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nYour import has produced one or more errors, " + "\nvisit the 'Import Errors' tab for details.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(this, "Errors Collected", false); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(frame); errorDialog.setVisible(true); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display errors in candidates dialog//ww w . ja v a 2s. c o m * * @param frame - parent frame */ public void candidateErrorsCollected(Component frame) { errors_pending = false; final JOptionPane optionPane = new JOptionPane( "\nAdding these files to the queue has produced one or more errors and some" + "\n files will not be displayed on the queue. View the 'Import Errors' tab for details.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(this, "Errors Collected", true); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(frame); errorDialog.setVisible(true); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display failed sending errors dialog/*from www . jav a 2 s .c om*/ * * @param frame - parent frame */ public void sendingErrorsFailed(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nDue to an error we were not able to send your error messages." + "\nto our feedback server. Please try again.", JOptionPane.WARNING_MESSAGE); final JDialog failedDialog = new JDialog(this, "Feedback Failed!", true); failedDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (failedDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { failedDialog.dispose(); } } }); failedDialog.toFront(); failedDialog.pack(); failedDialog.setLocationRelativeTo(frame); failedDialog.setVisible(true); }
From source file:ome.formats.importer.gui.ImportDialog.java
/** * Dialog explaining metadata limitations when changing the main dialog's naming settings * /*from www . ja v a 2 s . c o m*/ * @param frame - parent component */ public void sendNamingWarning(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nNOTE: Some file formats do not include the file name in their metadata, " + "\nand disabling this option may result in files being imported without a " + "\nreference to their file name. For example, 'myfile.lsm [image001]' " + "\nwould show up as 'image001' with this optioned turned off.", JOptionPane.WARNING_MESSAGE); final JDialog warningDialog = new JDialog(this, "Naming Warning!", true); warningDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (warningDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { warningDialog.dispose(); } } }); warningDialog.toFront(); warningDialog.pack(); warningDialog.setLocationRelativeTo(frame); warningDialog.setVisible(true); }
From source file:openblocks.yacodeblocks.DeviceReplCommController.java
private void rendevzousIpAddress() { // Generate the random 6 digit code and the QRCode that contains it. String AB = "abcdefghijklmnopqrstuvwxyz"; Random rnd = new Random(); StringBuilder sb = new StringBuilder(6); for (int i = 0; i < 6; i++) sb.append(AB.charAt(rnd.nextInt(AB.length()))); final String code = sb.toString(); final ImageIcon qrcode = generateQRCode(code); stopWireless = false; // Re-initialize in case it was set in a previous attempt final JDialog displayedCode = FeedbackReporter.showWirelessCodeDialog(code, qrcode, new Runnable() { public void run() { setStopWireless();//from w w w . j a v a 2 s . co m } }); Thread t = new Thread(new Runnable() { public void run() { try { // Put up the wireless dialog box Thread.sleep(4000); // Sleep 4 seconds, time to give the user a chance to start the Companion App String jsonString = fetchJsonString(code); int count = 0; while (jsonString == null) { if (count++ > 56) { // This limits this loop to about a minute (4 seconds wait above and 56 seconds round the loop) javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { displayedCode.setVisible(false); // Take down pending message FeedbackReporter.showErrorMessage( "We failed to find your phone, please try again.", "Try Again"); } }); return; } if (stopWireless) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { displayedCode.setVisible(false); // Take down pending message } }); return; } Thread.sleep(1000); // Pause a second (so the total wait time for the first loop is really 5 seconds subsequent loops are 1 second if (DEBUG) System.out.println("DeviceReplCommController (WiFi Connect) looping count = " + count); jsonString = fetchJsonString(code); } JSONObject jsonObject = new JSONObject(jsonString); final String ipAddress = (String) jsonObject.get("ipaddr"); if (DEBUG) System.out.println("Got ipaddr = " + ipAddress); // We have the IP address, we now send our version to the phone which // starts the phone TelnetRepl listening. If this version doesn't match // The phone will display an error and not listen. We don't need to know // the result because if the phone fails to listen it will reject the // connection that is attempted when we call selectDevice() String curl = "http://" + ipAddress + ":8000/_version?version=" + YaVersion.YOUNG_ANDROID_VERSION; if (DEBUG) System.out.println("Connecting to: " + curl); URL url = new URL(curl); URLConnection con = null; try { con = url.openConnection(); con.getInputStream().close(); // We don't care about the return value } catch (FileNotFoundException fnf) { System.out.println("Exception setting version, ignoring for now."); fnf.printStackTrace(System.out); // Let's not hide it though! } javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { displayedCode.setVisible(false); selectDevice("WiFi", ipAddress); // This is run on the UI thread } }); } catch (Exception e) { System.out.println("It did not work." + e.toString());//return e.printStackTrace(System.out); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { if (displayedCode != null) displayedCode.setVisible(false); } }); } } }); t.start(); }