List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:pcgen.gui2.PCGenFrame.java
private void showLicenseDialog(String title, String htmlString) { if (htmlString == null) { htmlString = LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$ }/* w w w.j a v a 2 s. com*/ final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; final JDialog aFrame = new JDialog(this, title, true); final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ final JPanel jPanel = new JPanel(); final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ jPanel.add(jCheckBox); jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_LICENSE)); jCheckBox.addItemListener( evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_LICENSE, jCheckBox.isSelected())); jPanel.add(jClose); jClose.addActionListener(evt -> aFrame.dispose()); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(htmlString, "", theRendererContext); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH); aFrame.setSize(new Dimension(700, 500)); aFrame.setLocationRelativeTo(this); Utility.setComponentRelativeLocation(this, aFrame); aFrame.getRootPane().setDefaultButton(jClose); Utility.installEscapeCloseOperation(aFrame); aFrame.setVisible(true); }
From source file:pcgen.gui2.PCGenFrame.java
private void showMatureDialog(String text) { Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised."); Logging.errorPrint(text);/* w w w . j a v a 2 s .c o m*/ final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true); final JPanel jPanel1 = new JPanel(); final JPanel jPanel3 = new JPanel(); final JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_matureWarningLine1"), //$NON-NLS-1$ SwingConstants.CENTER); final JLabel jLabel2 = new JLabel(LanguageBundle.getString("in_matureWarningLine2"), //$NON-NLS-1$ SwingConstants.CENTER); final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ jPanel1.setLayout(new BorderLayout()); jPanel1.add(jLabel1, BorderLayout.NORTH); jPanel1.add(jLabel2, BorderLayout.SOUTH); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(text, "", theRendererContext); jPanel3.add(jCheckBox1); jPanel3.add(jClose); final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD)); jClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { aFrame.dispose(); } }); jCheckBox1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected()); } }); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH); aFrame.setSize(new Dimension(456, 176)); Utility.setComponentRelativeLocation(this, aFrame); aFrame.setVisible(true); }
From source file:pipeline.misc_util.Utils.java
public static void displayMessage(final String s, boolean logMessage, final int logLevel) { Utils.log("Displaying message: " + s, LogLevel.ERROR); if ((!headless) && (!suppressWarningPopups)) SwingUtilities.invokeLater(() -> { JLabel textLabel = new JLabel(encodeHTML(WordUtils.wrap(s, 50)).replace("\n", "<br>\n")); int level; if (logLevel >= LogLevel.INFO) level = JOptionPane.INFORMATION_MESSAGE; else if (logLevel == LogLevel.WARNING) level = JOptionPane.WARNING_MESSAGE; else//from ww w .ja v a 2s. c o m level = JOptionPane.ERROR_MESSAGE; JOptionPane optionPane = new JOptionPane(); optionPane.setMessageType(level); optionPane.setMessage(textLabel); JDialog dialog = optionPane.createDialog("Pipeline message"); dialog.setAlwaysOnTop(true); dialog.setVisible(true); // JOptionPane.showMessageDialog(null, textLabel,"Pipeline message",level); }); }
From source file:pl.otros.logview.gui.actions.ChekForNewVersionOnStartupAction.java
@Override protected void handleNewVersionIsAvailable(final String current, String running) { LOGGER.info(String.format("Running version is %s, current is %s", running, current)); DataConfiguration configuration = getOtrosApplication().getConfiguration(); String doNotNotifyThisVersion = configuration .getString(ConfKeys.VERSION_CHECK_SKIP_NOTIFICATION_FOR_VERSION, "2000-01-01"); if (current != null && doNotNotifyThisVersion.compareTo(current) > 0) { return;// w ww . j a v a 2s .co m } JPanel message = new JPanel(new GridLayout(4, 1, 4, 4)); message.add(new JLabel(String.format("New version %s is available", current))); JButton button = new JButton("Open download page"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop() .browse(new URI("https://sourceforge.net/projects/otroslogviewer/files/?source=app")); } catch (Exception e1) { String msg = "Can't open browser with download page: " + e1.getMessage(); LOGGER.severe(msg); getOtrosApplication().getStatusObserver().updateStatus(msg, StatusObserver.LEVEL_ERROR); } } }); message.add(button); final JCheckBox chboxDoNotNotifyMeAboutVersion = new JCheckBox("Do not notify me about version " + current); message.add(chboxDoNotNotifyMeAboutVersion); final JCheckBox chboxDoNotCheckVersionOnStart = new JCheckBox("Do not check for new version on startup"); message.add(chboxDoNotCheckVersionOnStart); final JDialog dialog = new JDialog((Frame) null, "New version is available"); dialog.getContentPane().setLayout(new BorderLayout(5, 5)); dialog.getContentPane().add(message); JPanel jp = new JPanel(new FlowLayout(FlowLayout.CENTER)); jp.add(new JButton(new AbstractAction("Ok") { /** * */ private static final long serialVersionUID = 7930093775785431184L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); if (chboxDoNotNotifyMeAboutVersion.isSelected()) { LOGGER.fine("Disabling new version notificiation for " + current); getOtrosApplication().getConfiguration() .setProperty(ConfKeys.VERSION_CHECK_SKIP_NOTIFICATION_FOR_VERSION, current); } if (chboxDoNotCheckVersionOnStart.isSelected()) { LOGGER.fine("Disabling new version check on start"); getOtrosApplication().getConfiguration().setProperty(ConfKeys.VERSION_CHECK_ON_STARTUP, false); } } })); dialog.getContentPane().add(jp, BorderLayout.SOUTH); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); }
From source file:pl.otros.vfs.browser.demo.TestBrowser.java
public static void main(final String[] args) throws InterruptedException, InvocationTargetException, SecurityException, IOException { if (args.length > 1) throw new IllegalArgumentException( "SYNTAX: java... " + TestBrowser.class.getName() + " [initialPath]"); SwingUtilities.invokeAndWait(new Runnable() { @Override/* ww w. j a va 2 s . c o m*/ public void run() { tryLoadSubstanceLookAndFeel(); final JFrame f = new JFrame("OtrosVfsBrowser demo"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); DataConfiguration dc = null; final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); File favoritesFile = new File("favorites.properties"); propertiesConfiguration.setFile(favoritesFile); if (favoritesFile.exists()) { try { propertiesConfiguration.load(); } catch (ConfigurationException e) { e.printStackTrace(); } } dc = new DataConfiguration(propertiesConfiguration); propertiesConfiguration.setAutoSave(true); final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null); comp.setSelectionMode(SelectionMode.FILES_ONLY); comp.setMultiSelectionEnabled(true); comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) { @Override public void actionPerformed(ActionEvent e) { FileObject[] selectedFiles = comp.getSelectedFiles(); System.out.println("Selected files count=" + selectedFiles.length); for (FileObject selectedFile : selectedFiles) { try { FileSize fileSize = new FileSize(selectedFile.getContent().getSize()); System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString()); byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l); JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes))); JDialog d = new JDialog(f); d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI()); d.getContentPane().add(sp); d.setSize(600, 400); d.setVisible(true); } catch (Exception e1) { LOGGER.error("Failed to read file", e1); JOptionPane.showMessageDialog(f, (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }); comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) { @Override public void actionPerformed(ActionEvent e) { f.dispose(); try { propertiesConfiguration.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } System.exit(0); } }); contentPane.add(comp); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); }
From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java
public ReturnValue showOpenDialog(Component parent, String title) { JDialog dialog = createDialog(parent); dialog.setTitle(title);//from w w w. java2 s. c om if (size == null) { dialog.pack(); } else { dialog.setSize(size); } dialog.setVisible(true); size = dialog.getSize(); return returnValue; }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Singleton pattern : private constructor Use instead. *//*from ww w . j ava 2 s . c o m*/ private MMMainFrame() { super(NODE_NAME, false, true, false, true); instancing = true; // -------------- // INITIALIZATION // -------------- _sysConfigFile = ""; _isConfigLoaded = false; _root = PluginPreferences.getPreferences().node(NODE_NAME); final MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // -------------- // PROGRESS FRAME // -------------- ThreadUtil.invokeLater(new Runnable() { @Override public void run() { _progressFrame = new IcyFrame("", false, false, false, false); _progressBar = new JProgressBar(); _progressBar.setString("Please wait while loading..."); _progressBar.setStringPainted(true); _progressBar.setIndeterminate(true); _progressBar.setMinimum(0); _progressBar.setMaximum(1000); _progressBar.setBounds(50, 50, 100, 30); _progressFrame.setSize(300, 100); _progressFrame.setResizable(false); _progressFrame.add(_progressBar); _progressFrame.addToMainDesktopPane(); loadConfig(true); if (_sysConfigFile == "") { instancing = false; return; } ThreadUtil.bgRun(new Runnable() { @Override public void run() { while (!_isConfigLoaded) { if (!instancing) return; try { Thread.sleep(10); } catch (InterruptedException e) { } } ThreadUtil.invokeLater(new Runnable() { @Override public void run() { // -------------------- // START INITIALIZATION // -------------------- if (_progressBar != null) getContentPane().remove(_progressBar); if (mCore == null) { close(); return; } // ReportingUtils.setCore(mCore); _afMgr = new AutofocusManager(MMMainFrame.this); acqMgr = new AcquisitionManager(); PositionList posList = new PositionList(); _camera_label = MMCoreJ.getG_Keyword_CameraName(); if (_camera_label == null) _camera_label = ""; try { setPositionList(posList); } catch (MMScriptException e1) { e1.printStackTrace(); } posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg); posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL); callback = new EventCallBackManager(); mCore.registerCallback(callback); engine_ = new AcquisitionWrapperEngineIcy(); engine_.setParentGUI(MMMainFrame.this); engine_.setCore(mCore, getAutofocusManager()); engine_.setPositionList(getPositionList()); setSystemMenuCallback(new MenuCallback() { @Override public JMenu getMenu() { JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu(); JMenuItem hconfig = new JMenuItem("Configuration Wizard"); hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE)); hconfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?", "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>")) return; notifyConfigAboutToChange(null); try { mCore.unloadAllDevices(); } catch (Exception e1) { e1.printStackTrace(); } String previous_config = _sysConfigFile; ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore, _sysConfigFile); configurator.setVisible(true); String res = configurator.getFileName(); if (_sysConfigFile == "" || _sysConfigFile == res || res == "") { _sysConfigFile = previous_config; loadConfig(); } refreshGUI(); notifyConfigChanged(null); } }); JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config"); menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE)); menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); menuPxSizeConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CalibrationListDlg dlg = new CalibrationListDlg(mCore); dlg.setDefaultCloseOperation(2); dlg.setParentGUI(MMMainFrame.this); dlg.setVisible(true); dlg.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { super.windowClosed(e); notifyConfigChanged(null); } }); notifyConfigAboutToChange(null); } }); JMenuItem loadConfigItem = new JMenuItem("Load Configuration"); loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE)); loadConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadConfig(); initializeGUI(); refreshGUI(); } }); JMenuItem saveConfigItem = new JMenuItem("Save Configuration"); saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE)); saveConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveConfig(); } }); JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration"); advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE)); advancedConfigItem.addActionListener(new ActionListener() { /** */ @Override public void actionPerformed(ActionEvent e) { new ToolTipFrame( "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool " + "in which you fill some data <br/>about your configuration that some " + "plugins may need to access to.<br/> Exemple: the real values of the magnification" + "of your objectives.</p></html>", "MM4IcyAdvancedConfig"); if (advancedDlg == null) advancedDlg = new AdvancedConfigurationDialog(); advancedDlg.setVisible(!advancedDlg.isVisible()); advancedDlg.setLocationRelativeTo(mainFrame); } }); JMenuItem loadPresetConfigItem = new JMenuItem( "Load Configuration Presets"); loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE)); loadPresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { notifyConfigAboutToChange(null); loadPresets(); notifyConfigChanged(null); } }); JMenuItem savePresetConfigItem = new JMenuItem( "Save Configuration Presets"); savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE)); savePresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { savePresets(); } }); JMenuItem aboutItem = new JMenuItem("About"); aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE)); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JDialog dialog = new JDialog(mainFrame, "About"); JPanel panel_container = new JPanel(); panel_container .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel center = new JPanel(new BorderLayout()); final JLabel value = new JLabel("<html><body>" + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost." + "<br/>Copyright 2011, Institut Pasteur</p><br/>" + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>" + "<i>This software is distributed free of charge in the hope that it will be<br/>" + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>" + "warranty of merchantability or fitness for a particular purpose. In no<br/>" + "event shall the copyright owner or contributors be liable for any direct,<br/>" + "indirect, incidental spacial, examplary, or consequential damages.<br/>" + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>" + "2010. All rights reserved.</i>" + "</p>" + "</body></html>"); JLabel link = new JLabel( "<html><a href=\"\">For more information, please follow this link.</a></html>"); link.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseevent) { NetworkUtil.openBrowser( "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager"); } }); value.setSize(new Dimension(50, 18)); value.setAlignmentX(SwingConstants.HORIZONTAL); value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0)); center.add(value, BorderLayout.CENTER); center.add(link, BorderLayout.SOUTH); JPanel panel_south = new JPanel(); panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS)); JButton btn = new JButton("OK"); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { dialog.dispose(); } }); panel_south.add(Box.createHorizontalGlue()); panel_south.add(btn); panel_south.add(Box.createHorizontalGlue()); dialog.setLayout(new BorderLayout()); panel_container.setLayout(new BorderLayout()); panel_container.add(center, BorderLayout.CENTER); panel_container.add(panel_south, BorderLayout.SOUTH); dialog.add(panel_container, BorderLayout.CENTER); dialog.setResizable(false); dialog.setVisible(true); dialog.pack(); dialog.setLocation( (int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); dialog.setLocationRelativeTo(mainFrame); } }); JMenuItem propertyBrowserItem = new JMenuItem("Property Browser"); propertyBrowserItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK)); propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE)); propertyBrowserItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editor.setVisible(!editor.isVisible()); } }); int idx = 0; toReturn.insert(hconfig, idx++); toReturn.insert(loadConfigItem, idx++); toReturn.insert(saveConfigItem, idx++); toReturn.insert(advancedConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(loadPresetConfigItem, idx++); toReturn.insert(savePresetConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(propertyBrowserItem, idx++); toReturn.insert(menuPxSizeConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(aboutItem, idx++); return toReturn; } }); saveConfigButton_ = new JButton("Save Button"); // SETUP _groupPad = new ConfigGroupPad(); _groupPad.setParentGUI(MMMainFrame.this); _groupPad.setFont(new Font("", 0, 10)); _groupPad.setCore(mCore); _groupPad.setParentGUI(MMMainFrame.this); _groupButtonsPanel = new ConfigButtonsPanel(); _groupButtonsPanel.setCore(mCore); _groupButtonsPanel.setGUI(MMMainFrame.this); _groupButtonsPanel.setConfigPad(_groupPad); // LEFT PART OF INTERFACE _panelConfig = new JPanel(); _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS)); _panelConfig.add(_groupPad, BorderLayout.CENTER); _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH); _panelConfig.setPreferredSize(new Dimension(300, 300)); // MIDDLE PART OF INTERFACE _panel_cameraSettings = new JPanel(); _panel_cameraSettings.setLayout(new GridLayout(5, 2)); _panel_cameraSettings.setMinimumSize(new Dimension(100, 200)); _txtExposure = new JTextField(); try { mCore.setExposure(90.0D); _txtExposure.setText(String.valueOf(mCore.getExposure())); } catch (Exception e2) { _txtExposure.setText("90"); } _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _txtExposure.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyevent) { if (keyevent.getKeyCode() == KeyEvent.VK_ENTER) setExposure(); } }); _panel_cameraSettings.add(new JLabel("Exposure [ms]: ")); _panel_cameraSettings.add(_txtExposure); _combo_binning = new JComboBox(); _combo_binning.setMaximumRowCount(4); _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _combo_binning.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeBinning(); } }); _panel_cameraSettings.add(new JLabel("Binning: ")); _panel_cameraSettings.add(_combo_binning); _combo_shutters = new JComboBox(); _combo_shutters.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { if (_combo_shutters.getSelectedItem() != null) { mCore.setShutterDevice((String) _combo_shutters.getSelectedItem()); _prefs.put(PREF_SHUTTER, (String) _combo_shutters .getItemAt(_combo_shutters.getSelectedIndex())); } } catch (Exception e) { e.printStackTrace(); } } }); _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _panel_cameraSettings.add(new JLabel("Shutter : ")); _panel_cameraSettings.add(_combo_shutters); ActionListener action_listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateHistogram(); } }; _cbAbsoluteHisto = new JCheckBox(); _cbAbsoluteHisto.addActionListener(action_listener); _cbAbsoluteHisto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected()); _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected()); } }); _panel_cameraSettings.add(new JLabel("Display absolute histogram ?")); _panel_cameraSettings.add(_cbAbsoluteHisto); _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit", "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" }); _comboBitDepth.addActionListener(action_listener); _comboBitDepth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex()); } }); _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _comboBitDepth.setEnabled(false); _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: ")); _panel_cameraSettings.add(_comboBitDepth); // Acquisition _panelAcquisitions = new JPanel(); _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS)); // Color settings _panelColorChooser = new JPanel(); _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS)); painterPreferences = MicroscopePainterPreferences.getInstance(); painterPreferences.setPreferences(_prefs.node("paintersPreferences")); painterPreferences.loadColors(); HashMap<String, Color> allColors = painterPreferences.getColors(); String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]); String[] columnNames = { "Painter", "Color", "Transparency" }; Object[][] data = new Object[allKeys.length][3]; for (int i = 0; i < allKeys.length; ++i) { final int actualRow = i; String actualKey = allKeys[i].toString(); data[i][0] = actualKey; data[i][1] = allColors.get(actualKey); final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha()); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent changeevent) { painterTable.setValueAt(slider, actualRow, 2); } }); data[i][2] = slider; } final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data); painterTable = new JTable(tableModel); painterTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tablemodelevent) { if (tablemodelevent.getType() == TableModelEvent.UPDATE) { int row = tablemodelevent.getFirstRow(); int col = tablemodelevent.getColumn(); String columnName = tableModel.getColumnName(col); String painterName = (String) tableModel.getValueAt(row, 0); if (columnName.contains("Color")) { // New color value int alpha = painterPreferences.getColor(painterName).getAlpha(); Color coloNew = (Color) tableModel.getValueAt(row, 1); painterPreferences.setColor(painterName, new Color(coloNew.getRed(), coloNew.getGreen(), coloNew.getBlue(), alpha)); } else if (columnName.contains("Transparency")) { // New alpha value Color c = painterPreferences.getColor(painterName); int alphaValue = ((JSlider) tableModel.getValueAt(row, 2)) .getValue(); painterPreferences.setColor(painterName, new Color(c.getRed(), c.getGreen(), c.getBlue(), alphaValue)); } /* * for (int i = 0; i < * tableModel.getRowCount(); ++i) { try { * String painterName = (String) * tableModel.getValueAt(i, 0); Color c = * (Color) tableModel.getValueAt(i, 1); int * alphaValue; if (ASpinnerChanged && * tablemodelevent.getFirstRow() == i) { * alphaValue = ((JSlider) * tableModel.getValueAt(i, 2)).getValue(); * } else { alphaValue = * painterPreferences.getColor * (painterPreferences * .getPainterName(i)).getAlpha(); } * painterPreferences.setColor(painterName, * new Color(c.getRed(), c.getGreen(), * c.getBlue(), alphaValue)); } catch * (Exception e) { System.out.println( * "error with painter table update"); } } */ } } }); painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70)); painterTable.setFillsViewportHeight(true); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(painterTable); // Set up renderer and editor for the Favorite Color // column. painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true)); painterTable.setDefaultEditor(Color.class, new ColorEditor()); painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255)); painterTable.setDefaultEditor(JSlider.class, new SliderEditor()); _panelColorChooser.add(scrollPane); _panelColorChooser.add(Box.createVerticalGlue()); _mainPanel = new JPanel(); _mainPanel.setLayout(new BorderLayout()); // EDITOR // will refresh the data and verify if any change // occurs. // editor = new PropertyEditor(MMMainFrame.this); // editor.setCore(mCore); // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); editor = new PropertyEditor(); editor.setGui(MMMainFrame.this); editor.setCore(mCore); editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); add(_mainPanel); initializeGUI(); loadPreferences(); refreshGUI(); setResizable(true); addToMainDesktopPane(); instanced = true; instancing = false; _singleton = MMMainFrame.this; setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addFrameListener(new IcyFrameAdapter() { @Override public void icyFrameClosing(IcyFrameEvent e) { customClose(); } }); acceptListener = new AcceptListener() { @Override public boolean accept(Object source) { close(); return _pluginListEmpty; } }; adapter = new MainAdapter() { @Override public void sequenceOpened(MainEvent event) { updateHistogram(); } }; Icy.getMainInterface().addCanExitListener(acceptListener); Icy.getMainInterface().addListener(adapter); } }); } }); } }); }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * load configuration file for the core/* w w w .j a v a2s. c om*/ */ void loadCMMCore(String path) { mCore = MicroscopeCore.getCore(); if (mCore == null) { ThreadUtil.invokeNow(new Runnable() { @Override public void run() { JDialog dialog = createDLLErrorDialog(); dialog.setVisible(true); } }); instancing = false; return; } /* * core.enableDebugLog(false); core.enableStderrLog(false); * core.shutdownLogging(); */ try { mCore.loadSystemConfiguration(path); try { StrVector pxSizeConfigs = mCore.getAvailablePixelSizeConfigs(); if (!(pxSizeConfigs.size() >= 1)) throw new Exception(); } catch (Exception e) { mCore.definePixelSizeConfig("ResDefault"); mCore.setPixelSizeUm("ResDefault", 1.0); } ThreadUtil.invokeLater(new Runnable() { @Override public void run() { { if (_groupPad != null) _groupPad.setCore(mCore); if (_groupButtonsPanel != null) _groupButtonsPanel.setCore(mCore); } } }); } catch (Exception e) { String res = e.getMessage(); if (res.contains("file not acessible or corrupted") || res.contains("Unable to load library")) { ThreadUtil.invokeNow(new Runnable() { @Override public void run() { JDialog dialog = createDLLErrorDialog(); dialog.setVisible(true); } }); } else { ThreadUtil.invokeNow(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(Icy.getMainInterface().getMainFrame().getRootPane(), "Error while initializing the microscope: please check if all devices are correctly turned on and recognized by the computer and" + "quit any program using those devices."); } }); } mCore = null; } }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Create an error dialog concerning DLL issues with Micro-Manager. * /*from w w w. j av a2 s .com*/ * @return Returns the dialog. */ private JDialog createDLLErrorDialog() { MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // Dialog frame to be returned final JDialog dialog = new JDialog(mainFrame, "Loading Error", true); // main panel of the dialog JPanel panel_main = new JPanel(); panel_main.setLayout(new BorderLayout()); JLabel lbl_html = new JLabel("<html>" + "<h2>Unable to load library</h2>" + "<br/><b>What happened ?</b>" + "<p>The library is a file used by Manager to interact with the devices. Each device needs a specific file in order <br/>" + "to work properly with the system. If only one file is missing, this error occurs.</p>" + "<b>To avoid getting this problem again, please acknowledge the following steps: </b>" + "<ol><li>Do you have Micro-Manager 1.4 installed ? If not, please install it via the button below.</li>" + "<li>Check the application directory of Icy. You should find a file named: " + "<ul><li>on Windows: MMCoreJ_wrap</li><li>on Mac: libMMCoreJ_wrap</li></ul>" + "<li>Plus : you should have a file for each of your devices starting with the name:" + "<ul><li>on Windows: mmgr_dal_</li><li>on Mac: libmmgr_dal_</li></ul>" + "<li>If you don't have these files, please copy (not move) them from the Manager application directory<br/>" + "to your Icy application directory.</li></ol></html>"); panel_main.add(lbl_html, BorderLayout.CENTER); panel_main.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel panel_buttons = new JPanel(); panel_buttons.setLayout(new BoxLayout(panel_buttons, BoxLayout.X_AXIS)); panel_buttons.add(Box.createHorizontalGlue()); JButton btn_link = new JButton(); btn_link.setText("Download Micro-Manager 1.4.14"); btn_link.setBackground(Color.WHITE); btn_link.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetworkUtil .openBrowser("http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager_Version_Archive"); } }); panel_buttons.add(btn_link); JButton btn_ok = new JButton("OK"); btn_ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); panel_buttons.add(btn_ok); panel_main.add(panel_buttons, BorderLayout.SOUTH); dialog.add(panel_main); dialog.pack(); dialog.setLocation((int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); return dialog; }
From source file:processing.app.Editor.java
/** * Check if the sketch is modified and ask user to save changes. * @return false if canceling the close/quit operation *///from www.j a v a 2 s. c om protected boolean checkModified() { if (!sketch.isModified()) return true; // As of Processing 1.0.10, this always happens immediately. // http://dev.processing.org/bugs/show_bug.cgi?id=1456 toFront(); String prompt = I18n.format(_("Save changes to \"{0}\"? "), sketch.getName()); if (!OSUtils.isMacOS()) { int result = JOptionPane.showConfirmDialog(this, prompt, _("Close"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.YES_OPTION: return handleSave(true); case JOptionPane.NO_OPTION: return true; // ok to continue case JOptionPane.CANCEL_OPTION: case JOptionPane.CLOSED_OPTION: // Escape key pressed return false; default: throw new IllegalStateException(); } } else { // This code is disabled unless Java 1.5 is being used on Mac OS X // because of a Java bug that prevents the initial value of the // dialog from being set properly (at least on my MacBook Pro). // The bug causes the "Don't Save" option to be the highlighted, // blinking, default. This sucks. But I'll tell you what doesn't // suck--workarounds for the Mac and Apple's snobby attitude about it! // I think it's nifty that they treat their developers like dirt. // Pane formatting adapted from the quaqua guide // http://www.randelshofer.ch/quaqua/guide/joptionpane.html JOptionPane pane = new JOptionPane(_("<html> " + "<head> <style type=\"text/css\">" + "b { font: 13pt \"Lucida Grande\" }" + "p { font: 11pt \"Lucida Grande\"; margin-top: 8px }" + "</style> </head>" + "<b>Do you want to save changes to this sketch<BR>" + " before closing?</b>" + "<p>If you don't save, your changes will be lost."), JOptionPane.QUESTION_MESSAGE); String[] options = new String[] { _("Save"), _("Cancel"), _("Don't Save") }; pane.setOptions(options); // highlight the safest option ala apple hig pane.setInitialValue(options[0]); // on macosx, setting the destructive property places this option // away from the others at the lefthand side pane.putClientProperty("Quaqua.OptionPane.destructiveOption", new Integer(2)); JDialog dialog = pane.createDialog(this, null); dialog.setVisible(true); Object result = pane.getValue(); if (result == options[0]) { // save (and close/quit) return handleSave(true); } else if (result == options[2]) { // don't save (still close/quit) return true; } else { // cancel? return false; } } }