List of usage examples for javax.swing JLabel addMouseListener
public synchronized void addMouseListener(MouseListener l)
From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private AbstractWizardPage getAddTagsPage() { //setup page/*from w w w. j ava 2s .com*/ final DefaultWizardPage page = new DefaultWizardPage("Add Tags") { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Variants can be filtered by tag value in the Filter section."); page.addText("Add tags for this set of variants:"); final String[] patternExamples = { "<Tag Name>", "Sequencer", "Sequencer Version", "Variant Caller", "Variant Caller Version", "Technician" }; locationField = new JComboBox(patternExamples); locationField.setEditable(true); final JPanel tagContainer = new JPanel(); ViewUtil.applyVerticalBoxLayout(tagContainer); final JTextField valueField = new JTextField(); final String startingValue = "<Value>"; valueField.setText(startingValue); final JTextArea ta = new JTextArea(); ta.setRows(10); ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ta.setEditable(false); JLabel button = ViewUtil.createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD)); button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (locationField.getSelectedItem().toString().isEmpty()) { DialogUtils.displayError("Tag cannot be empty"); locationField.requestFocus(); return; } else if (locationField.getSelectedItem().toString().equals(patternExamples[0])) { DialogUtils.displayError("Enter a valid tag name"); locationField.requestFocus(); return; } if (valueField.getText().toString().isEmpty()) { DialogUtils.displayError("Value cannot be empty"); valueField.requestFocus(); return; } else if (valueField.getText().equals(startingValue)) { DialogUtils.displayError("Enter a valid value"); valueField.requestFocus(); return; } VariantTag tag = new VariantTag((String) locationField.getSelectedItem(), valueField.getText()); variantTags.add(tag); ta.append(tag.toString() + "\n"); valueField.setText(""); } }); JPanel container2 = new JPanel(); ViewUtil.clear(container2); ViewUtil.applyHorizontalBoxLayout(container2); container2.add(locationField); container2.add(ViewUtil.clear(new JLabel(" = "))); container2.add(valueField); container2.add(button); page.addComponent(container2); locationField.setToolTipText("Current display range"); locationField.setPreferredSize(LOCATION_SIZE); locationField.setMinimumSize(LOCATION_SIZE); valueField.setPreferredSize(LOCATION_SIZE); valueField.setMinimumSize(LOCATION_SIZE); page.addComponent(tagContainer); page.addComponent(new JScrollPane(ta)); JButton clear = new JButton("Clear"); clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantTags.clear(); ta.setText(""); addDefaultTags(variantTags, ta); } }); addDefaultTags(variantTags, ta); page.addComponent(ViewUtil.alignRight(clear)); return page; }
From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java
public void addKey(final String key, boolean showExpand) { Color rowColor = Color.WHITE; if (keyKeyComponentMap.size() % 2 == 0) { rowColor = ViewUtil.getAlternateRowColor(); }//from w w w . j a va2 s. c om if (newRowsGoIntoMoreSection) { keysInMoreSection.add(key); } rowColor = Color.white; String layoutConstraints = "insets 3 3 3 3, filly"; JPanel valuePanel = ViewUtil.getClearPanel(); valuePanel.setLayout(new MigLayout(layoutConstraints)); valuePanel.setBackground(rowColor); int i = 0; JPanel keyPanel = ViewUtil.getClearPanel(); keyPanel.setLayout(new MigLayout(layoutConstraints + ", alignx right, hmin 30")); keyPanel.setBackground(rowColor); final JLabel keyLabel = getKeyLabel(key); //keyLabel.setBorder(ViewUtil.getMediumBorder()); keyKeyComponentMap.put(key, keyLabel); if (showExpand) { keyLabel.setText("? " + key.toUpperCase()); keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); keyLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { toggleMoreVisibility(); if (keyLabel.getText().startsWith("?")) { keyLabel.setText("? " + key.toUpperCase()); } else { keyLabel.setText("? " + key.toUpperCase()); } } }); } keyPanel.add(keyLabel); keyLabel.setVisible(keysVisible); kvpPanel.add(keyPanel, incrementConstraintRow(i++)); kvpPanel.add(valuePanel, incrementConstraintRow(i++)); JPanel[] extraComponents = new JPanel[additionalColumns]; for (int j = 0; j < additionalColumns; j++) { JPanel panel = ViewUtil.getClearPanel(); panel.setBackground(rowColor); ViewUtil.applyHorizontalBoxLayout(panel); //panel.setBorder(border); //panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); extraComponents[j] = panel;//ViewUtil.getClearPanel(); kvpPanel.add(extraComponents[j], incrementConstraintRow(i++)); } // add hidden panel keyDetailConstraints.gridy++; keyDetailConstraints.gridy++; JPanel detailPanel = ViewUtil.getClearPanel(); detailPanel.setBackground(rowColor); //detailPanel.setBorder(ViewUtil.getTinyLineBorder()); detailPanel.setVisible(false); keyDetailComponentMap.put(key, detailPanel); kvpPanel.add(detailPanel, keyDetailConstraints); // update all constraints to skip a line for (int k = 0; k < 2 + additionalColumns; k++) { incrementConstraintRow(k); } keyValueComponentMap.put(key, valuePanel); keyExtraComponentsMap.put(key, extraComponents); setMoreVisibility(showingMore); }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsGeneSubInspector.java
@Override protected JPanel getIndividualSummaryPanel(String dnaID) { JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); //dnaIDVariantMap.get(DNAId) -- all variants within gene corresponding to individual Set<VariantRecord> variantRecords = getVariantRecords(dnaID); Map<Long, Set<VariantRecord>> positionVariantMap = new TreeMap<Long, Set<VariantRecord>>(); for (VariantRecord variantRecord : variantRecords) { //Get all variants at that overlap at that position, regardless of individual. Set<VariantRecord> variantsAtPosition = positionVariantMap.get(variantRecord.getStartPosition()); if (variantsAtPosition == null) { variantsAtPosition = new HashSet<VariantRecord>(); }// ww w. j av a 2s. com variantsAtPosition.add(variantRecord); positionVariantMap.put(variantRecord.getStartPosition(), variantsAtPosition); } for (Map.Entry<Long, Set<VariantRecord>> e : positionVariantMap.entrySet()) { Long pos = e.getKey(); Set<VariantRecord> variantsAtPosition = e.getValue(); for (final VariantRecord variantRecord : variantsAtPosition) { final JPanel rowContainer = new JPanel(); rowContainer.setLayout(new BoxLayout(rowContainer, BoxLayout.Y_AXIS)); final JPanel row = new JPanel(); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); row.setBorder(new EmptyBorder(0, MIDDLE_LEVEL_INDENT, 0, 0)); final JLabel showDetailsButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); String posStr = NumberFormat.getNumberInstance().format(pos); JLabel rowTitle = new JLabel( " " + variantRecord.getZygosity().name() + " " + variantRecord.getType() + " @ " + posStr); row.add(showDetailsButton); row.add(rowTitle); row.add(Box.createHorizontalGlue()); rowContainer.add(row); outerPanel.add(rowContainer); showDetailsButton.addMouseListener(new MouseAdapter() { private boolean expanded = true; @Override public void mousePressed(MouseEvent me) { if (expanded) { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COLLAPSE)); int last_level_indent = MIDDLE_LEVEL_INDENT + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND) .getIconWidth() + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' '); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new EmptyBorder(0, last_level_indent, 0, 0)); JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Ref: " + variantRecord.getRef())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Alt: " + variantRecord.getAlt())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); rowContainer.add(p); } else { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); rowContainer.removeAll(); rowContainer.add(row); } rowContainer.revalidate(); rowContainer.repaint(); expanded = !expanded; } }); } } return outerPanel; }
From source file:org.ut.biolab.medsavant.client.view.list.MasterView.java
public MasterView(String page, DetailedListModel model, DetailedView view, DetailedListEditor editor) { pageName = page;/* w w w .j a va 2 s . com*/ detailedModel = model; detailedView = view; detailedEditor = editor; setLayout(new CardLayout()); WaitPanel wp = new WaitPanel("Getting list"); wp.setBackground(ViewUtil.getTertiaryMenuColor()); add(wp, CARD_WAIT); showCard = new JPanel(); add(showCard, CARD_SHOW); JPanel errorPanel = new JPanel(); errorPanel.setLayout(new BorderLayout()); errorMessage = new JLabel("An error occurred:"); errorPanel.add(errorMessage, BorderLayout.NORTH); add(errorPanel, CARD_ERROR); buttonPanel = ViewUtil.getClearPanel(); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = GridBagConstraints.RELATIVE; gbc.gridy = 0; gbc.insets = new Insets(3, 3, 3, 3); if (detailedEditor.doesImplementAdding()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD_ON_TOOLBAR)); butt.setToolTipText("Add"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.addItems(); // In some cases, such as uploading/publishing variants, the addItems() method may have logged us out. if (LoginController.getInstance().isLoggedIn()) { refreshList(); } } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementImporting()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.IMPORT)); butt.setToolTipText("Import"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.importItems(); refreshList(); } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementExporting()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPORT)); butt.setToolTipText("Export"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.exportItems(); refreshList(); } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementDeleting()) { JLabel butt = ViewUtil.createIconButton( IconFactory.getInstance().getIcon(IconFactory.StandardIcon.REMOVE_ON_TOOLBAR)); butt.setToolTipText("Remove selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.deleteItems(selectionGrabber.getSelectedItems()); // In some cases, such as removing/publishing variants, the deleteItems() method may have logged us out. if (LoginController.getInstance().isLoggedIn()) { refreshList(); } } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementEditing()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EDIT)); butt.setToolTipText("Edit selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (selectionGrabber.getSelectedItems().size() > 0) { detailedEditor.editItem(selectionGrabber.getSelectedItems().get(0)); refreshList(); } else { DialogUtils.displayMessage("Please choose one item to edit."); } } }); buttonPanel.add(butt, gbc); } // Only for SavedFiltersPanel if (detailedEditor.doesImplementLoading()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LOAD_ON_TOOLBAR)); butt.setToolTipText("Load selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.loadItems(selectionGrabber.getSelectedItems()); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.EAST; buttonPanel.add(butt, gbc); } showWaitCard(); fetchList(); }
From source file:org.ut.biolab.medsavant.client.view.UpdatesPanel.java
private void showPopup(final int start) { popup = new JPopupMenu(); popup.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); if (notifications == null) { popup.add(new NotificationIcon(null, null)); } else {//from w ww.j av a 2s .co m //add notifications for (int i = start; i < Math.min(start + 5, notifications.length); i++) { popup.add(new NotificationIcon(notifications[i], popup)); if (i != Math.min(start + 5, notifications.length) - 1) { popup.add(createSeparator()); } } //add page header if (notifications.length > 5) { JPanel header = new JPanel(); header.setMinimumSize(new Dimension(1, 15)); header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS)); if (start >= 5) { JLabel prevButton = ViewUtil.createLabelButton(" Prev Page "); prevButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showPopup(start - 5); } }); header.add(prevButton); } header.add(Box.createHorizontalGlue()); if (start + 5 < notifications.length) { JLabel nextButton = ViewUtil.createLabelButton(" Next Page "); nextButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showPopup(start + 5); } }); header.add(nextButton); } popup.add(createSeparator()); popup.add(header); } } //int offset = -Math.min(5, notifications.length - start) * (MENU_ICON_SIZE.height + 2) -3 - (headerAdded ? 16 : 0); popup.show(this, 0, this.getPreferredSize().height); }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Singleton pattern : private constructor Use instead. *//*w w w. j a v a2 s . c om*/ 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:projectresurrection.Music.java
public void subMenu(int menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);//from w w w .j a v a 2 s. com JLabel header = (JLabel) pnlSub.getComponent(1); JLabel label; panel.removeAll(); int y = 10; switch (menu) { case 0: header.setText("Artists"); panel.setPreferredSize(new Dimension(349, (55 + (artists.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; List artistList = new ArrayList(artists.keySet()); Collections.sort(artistList); for (int i = 0; i < artistList.size(); i++) { String artist = artistList.get(i).toString(); label = new JLabel(artist); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ARTISTS, artist); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 1: header.setText("Albums"); panel.setPreferredSize(new Dimension(349, (55 + (albums.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(SONGS); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; List albumList = new ArrayList(albums.keySet()); Collections.sort(albumList); for (int i = 0; i < albumList.size(); i++) { String album = albumList.get(i).toString(); label = new JLabel(album); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS, album); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 2: header.setText("Songs"); panel.setPreferredSize(new Dimension(349, (20 + (songs.size() * 35)))); List songList = new ArrayList(songs.keySet()); Collections.sort(songList); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } pnlMenu.setVisible(false); pnlSub.setVisible(true); }
From source file:projectresurrection.Music.java
public void subMenu(int type, String menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);/*from w w w.ja v a2s .co m*/ JLabel header = (JLabel) pnlSub.getComponent(1); JLabel label; header.setText(menu); panel.removeAll(); int y = 10; switch (type) { case 0: List albumList = new ArrayList(((Map) artists.get(menu)).keySet()); Collections.sort(albumList); panel.setPreferredSize(new Dimension(349, (55 + (albumList.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenuAll(ARTISTS, menu); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; for (int i = 0; i < albumList.size(); i++) { String album = albumList.get(i).toString(); label = new JLabel(album); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS, album); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 1: List songList = new ArrayList(); List albumSongs = new ArrayList(((Map) albums.get(menu)).keySet()); Collections.sort(albumSongs); Map tracks = new HashMap(); for (int i = 0; i < albumSongs.size(); i++) { String track = ((List) songs.get(albumSongs.get(i))).get(1).toString(); if (tracks.containsKey(track)) { track = track + "(1)"; int j = 2; while (tracks.containsKey(track)) { track = track + "(" + j + ")"; } } tracks.put(track, albumSongs.get(i)); } List nums = new ArrayList(tracks.keySet()); Collections.sort(nums); List hasTrack = new ArrayList(); List noTrack = new ArrayList(); for (int i = 0; i < nums.size(); i++) { if (nums.get(i).equals("-1")) { noTrack.add(tracks.get(nums.get(i))); } else { hasTrack.add(tracks.get(nums.get(i))); } } Collections.sort(noTrack); for (int i = 0; i < hasTrack.size(); i++) { songList.add(hasTrack.get(i)); } for (int i = 0; i < noTrack.size(); i++) { songList.add(noTrack.get(i)); } panel.setPreferredSize(new Dimension(349, (20 + (albumSongs.size() * 35)))); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } panel.revalidate(); panel.repaint(); }
From source file:projectresurrection.Music.java
public void subMenuAll(int type, String menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);/*ww w.ja va 2s. c o m*/ JLabel header = (JLabel) pnlSub.getComponent(1); header.setText(menu + " - All"); panel.removeAll(); int y = 10; switch (type) { case 0: List songList = new ArrayList(); List albumList = new ArrayList(((Map) artists.get(menu)).keySet()); Collections.sort(albumList); for (int i = 0; i < albumList.size(); i++) { List albumSongs = new ArrayList(((Map) albums.get(albumList.get(i))).keySet()); Map tracks = new HashMap(); for (int j = 0; j < albumSongs.size(); j++) { String track = ((List) songs.get(albumSongs.get(j))).get(1).toString(); tracks.put(track, albumSongs.get(j)); } List nums = new ArrayList(tracks.keySet()); Collections.sort(nums); List hasTrack = new ArrayList(); List noTrack = new ArrayList(); for (int j = 0; j < nums.size(); j++) { if (nums.get(j).equals("-1")) { noTrack.add(tracks.get(nums.get(j))); } else { hasTrack.add(tracks.get(nums.get(j))); } } for (int j = 0; j < hasTrack.size(); j++) { songList.add(hasTrack.get(j)); } for (int j = 0; j < noTrack.size(); j++) { songList.add(noTrack.get(j)); } } panel.setPreferredSize(new Dimension(349, (20 + (songList.size() * 35)))); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); JLabel label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } panel.revalidate(); panel.repaint(); }
From source file:Provider.GoogleMapsStatic.TestUI.SampleApp.java
private void _displayImgInFrame() { final JFrame frame = new JFrame("Google Static Map"); GUIUtils.setAppIcon(frame, "71.png"); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JLabel imgLbl = new JLabel(new ImageIcon(_img)); imgLbl.setToolTipText(MessageFormat.format("<html>Image downloaded from URI<br>size: w={0}, h={1}</html>", _img.getWidth(), _img.getHeight())); imgLbl.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { }//from w w w . j av a 2 s .com public void mousePressed(MouseEvent e) { frame.dispose(); } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } }); frame.setContentPane(imgLbl); frame.pack(); GUIUtils.centerOnScreen(frame); frame.setVisible(true); }