List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:org.nuxeo.launcher.gui.NuxeoFrame.java
protected JComponent buildTabbedPanel() { tabbedPanel = new JTabbedPane(SwingConstants.TOP); tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.summary.title"), buildSummaryPanel()); logsTab = buildLogsTab();// w w w .j a v a 2s .c om tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.logs.title"), logsTab); tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.shell.title"), buildConsolePanel()); tabbedPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JTabbedPane pane = (JTabbedPane) e.getSource(); if (pane.getSelectedIndex() == 2) { consolePanel.getConsole().requestFocusInWindow(); } } }); return tabbedPanel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createScanPanel() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel tablePanel = new JPanel(); tablePanel.setLayout(new BorderLayout()); tablePanel.setBorder(new TitledBorder("Tables to scan")); tableList = new JList<String>(); tableList.setToolTipText("Specify the tables (or CSV files) to be scanned here"); tablePanel.add(new JScrollPane(tableList), BorderLayout.CENTER); JPanel tableButtonPanel = new JPanel(); tableButtonPanel.setLayout(new GridLayout(3, 1)); addAllButton = new JButton("Add all in DB"); addAllButton.setToolTipText("Add all tables in the database"); addAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addAllTables();//from w w w. ja v a 2 s . c om } }); addAllButton.setEnabled(false); tableButtonPanel.add(addAllButton); JButton addButton = new JButton("Add"); addButton.setToolTipText("Add tables to list"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickTables(); } }); tableButtonPanel.add(addButton); JButton removeButton = new JButton("Remove"); removeButton.setToolTipText("Remove tables from list"); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeTables(); } }); tableButtonPanel.add(removeButton); tablePanel.add(tableButtonPanel, BorderLayout.EAST); panel.add(tablePanel, BorderLayout.CENTER); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS)); JPanel scanOptionsPanel = new JPanel(); scanOptionsPanel.setLayout(new BoxLayout(scanOptionsPanel, BoxLayout.X_AXIS)); scanValueScan = new JCheckBox("Scan field values", true); scanValueScan.setToolTipText("Include a frequency count of field values in the scan report"); scanValueScan.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { scanMinCellCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanRowCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanValuesCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); } }); scanOptionsPanel.add(scanValueScan); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Min cell count ")); scanMinCellCount = new JSpinner(); scanMinCellCount.setValue(5); scanMinCellCount.setToolTipText("Minimum frequency for a field value to be included in the report"); scanOptionsPanel.add(scanMinCellCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Max distinct values ")); scanValuesCount = new JComboBox<String>(new String[] { "100", "1,000", "10,000" }); scanValuesCount.setSelectedIndex(1); scanValuesCount.setToolTipText("Maximum number of distinct values per field to be reported"); scanOptionsPanel.add(scanValuesCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Rows per table ")); scanRowCount = new JComboBox<String>(new String[] { "100,000", "500,000", "1 million", "all" }); scanRowCount.setSelectedIndex(0); scanRowCount.setToolTipText("Maximum number of rows per table to be scanned for field values"); scanOptionsPanel.add(scanRowCount); southPanel.add(scanOptionsPanel); southPanel.add(Box.createVerticalStrut(3)); JPanel scanButtonPanel = new JPanel(); scanButtonPanel.setLayout(new BoxLayout(scanButtonPanel, BoxLayout.X_AXIS)); scanButtonPanel.add(Box.createHorizontalGlue()); JButton scanButton = new JButton("Scan tables"); scanButton.setBackground(new Color(151, 220, 141)); scanButton.setToolTipText("Scan the selected tables"); scanButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scanRun(); } }); componentsToDisableWhenRunning.add(scanButton); scanButtonPanel.add(scanButton); southPanel.add(scanButtonPanel); panel.add(southPanel, BorderLayout.SOUTH); return panel; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java
/** Initializes the components. */ private void initComponents() { messageLabel = new JXLabel(); messageLabel.setText(TEXT_REFRESH);//from w w w . j a v a2s .co m messageLabel.setVisible(false); messageLabel.setFont(messageLabel.getFont().deriveFont(Font.BOLD)); controlsBar = buildControls(); controlsBar.setVisible(false); uiElementID = 0; uiElements = new LinkedHashMap<Integer, ImporterUIElement>(); tabs = new ClosableTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); tabs.setAlignmentX(LEFT_ALIGNMENT); tabs.addPropertyChangeListener(controller); tabs.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { controlsBar.setVisible(tabs.getSelectedIndex() != 0); controller.getAction(ImporterControl.RETRY_BUTTON).setEnabled(hasFailuresToReupload()); controller.getAction(ImporterControl.SEND_BUTTON).setEnabled(hasFailuresToSend()); } }); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.util.SaveResultsDialog.java
/** Initializes the components. * /*ww w .ja v a2 s .c om*/ * @param index The index indicating what to save. */ private void initialize(int index) { activeWindow = true; cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancel(); } }); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); } }); ChangeListener l = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { saveButton.setEnabled(roi.isSelected() || table.isSelected()); } }; roi = new JCheckBox("ROI"); roi.addChangeListener(l); table = new JCheckBox("Measurements"); table.addChangeListener(l); nameField = new JTextField(15); if (index == SaveEvent.ALL) { roi.setSelected(true); table.setSelected(true); } else if (index == SaveEvent.ROIS) { roi.setSelected(true); } else if (index == SaveEvent.RESULTS) { table.setSelected(true); } }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java
/** * Returns the {@link ChangeListener} attached to the tab pane, * or creates one if none initialized./*from w ww.j a v a 2 s.co m*/ * * @return See above. */ ChangeListener getTabbedListener() { if (tabsListener == null) { tabsListener = new ChangeListener() { // This method is called whenever the selected tab changes public void stateChanged(ChangeEvent ce) { JTabbedPane pane = (JTabbedPane) ce.getSource(); model.clearFoundResults(); Component c = pane.getSelectedComponent(); if (c == null) { model.setSelectedBrowser(null, true); return; } Map browsers = model.getBrowsers(); Iterator i = browsers.values().iterator(); boolean selected = false; Browser browser; while (i.hasNext()) { browser = (Browser) i.next(); if (c.equals(browser.getUI())) { model.setSelectedBrowser(browser, true); selected = true; break; } } if (!selected) model.setSelectedBrowser(null, true); } }; } return tabsListener; }
From source file:org.pentaho.ui.xul.swing.tags.SwingCheckbox.java
public void setCommand(final String method) { oncommand = method;//from ww w. ja v a 2s . c o m checkBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { if (SwingCheckbox.this.initialized) { invoke(method); } } }); }
From source file:org.pentaho.ui.xul.swing.tags.SwingRadio.java
public void setCommand(final String method) { radioButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { invoke(method);/*from w w w. ja v a 2 s . co m*/ } }); }
From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java
private void initListeners() { ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().addChangeListener(new ChangeListener() { @Override/* w w w . j a va 2s . c om*/ public void stateChanged(ChangeEvent e) { if (EditorUtils.getCurrentActiveEditor() != null) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (editor.getSelectedItem() != null && editor.getSelectedItem() instanceof Ellipse) { Ellipse el = (Ellipse) editor.getSelectedItem(); int angle = ((Integer) ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner() .getValue()).intValue(); el.setStartAngle(angle); editor.refresh(); editor.setFileState(FileState.DIRTY); } } } }); ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (EditorUtils.getCurrentActiveEditor() != null) { if (editor.getSelectedItem() != null && editor.getSelectedItem() instanceof Ellipse) { Ellipse el = (Ellipse) editor.getSelectedItem(); int rotation = ((Integer) ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner() .getValue()).intValue(); el.setRotation(rotation); editor.refresh(); editor.setFileState(FileState.DIRTY); } } } }); ctx.getBean(ShapePropertiesPanel.class).getStyleCombo().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (EditorUtils.getCurrentActiveEditor() != null) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (editor.getSelectedItem() != null) { if (editor.getSelectedItem() instanceof Shape) { Shape shape = (Shape) editor.getSelectedItem(); shape.setStyle((ShapeStyle) ctx.getBean(ShapePropertiesPanel.class).getStyleCombo() .getSelectedItem()); editor.refresh(); editor.setFileState(FileState.DIRTY); } } else if (editor.getSelectedItems().size() > 0) { for (Item item : editor.getSelectedItems()) { if (item instanceof Shape) { Shape shape = (Shape) item; shape.setStyle((ShapeStyle) ctx.getBean(ShapePropertiesPanel.class).getStyleCombo() .getSelectedItem()); } } editor.setFileState(FileState.DIRTY); editor.refresh(); } } } }); ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ShapePropertiesPanel panel = ctx.getBean(ShapePropertiesPanel.class); if (EditorUtils.getCurrentActiveEditor() != null) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (editor.getSelectedItem() != null) { if (editor.getSelectedItem() instanceof Shape) { Shape shape = (Shape) editor.getSelectedItem(); shape.setStroke((BasicStroke) panel.getThicknessCombo().getSelectedItem()); editor.refresh(); } } else if (editor.getSelectedItems().size() > 0) { for (Item item : editor.getSelectedItems()) { if (item instanceof Shape) { Shape shape = (Shape) item; shape.setStroke((BasicStroke) panel.getThicknessCombo().getSelectedItem()); } } editor.setFileState(FileState.DIRTY); editor.refresh(); } } // Preserve settings if (panel.getThicknessCombo().getSelectedItem() != null) { panel.setLastSelectedStroke((BasicStroke) panel.getThicknessCombo().getSelectedItem()); } } }); ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ShapePropertiesPanel panel = ctx.getBean(ShapePropertiesPanel.class); if (EditorUtils.getCurrentActiveEditor() != null) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (editor.getSelectedItem() != null) { if (editor.getSelectedItem() instanceof Line) { Line line = (Line) editor.getSelectedItem(); line.setStartType((LineEdgeType) panel.getStartLineCombo().getSelectedItem()); editor.refresh(); } } else if (editor.getSelectedItems().size() > 0) { for (Item item : editor.getSelectedItems()) { if (item instanceof Line) { Line line = (Line) item; line.setStartType((LineEdgeType) panel.getStartLineCombo().getSelectedItem()); } } editor.setFileState(FileState.DIRTY); editor.refresh(); } } // Preserve settings if (panel.getStartLineCombo().getSelectedItem() != null) { panel.setLastSelectedLineStartStyle((LineEdgeType) panel.getStartLineCombo().getSelectedItem()); } } }); ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ShapePropertiesPanel panel = ctx.getBean(ShapePropertiesPanel.class); if (EditorUtils.getCurrentActiveEditor() != null) { BoardEditor editor = EditorUtils.getCurrentActiveEditor(); if (editor.getSelectedItem() != null) { if (editor.getSelectedItem() instanceof Line) { Line line = (Line) editor.getSelectedItem(); line.setEndType((LineEdgeType) panel.getEndLineCombo().getSelectedItem()); editor.refresh(); } } else if (editor.getSelectedItems().size() > 0) { for (Item item : editor.getSelectedItems()) { if (item instanceof Line) { Line line = (Line) item; line.setEndType((LineEdgeType) panel.getEndLineCombo().getSelectedItem()); } } editor.setFileState(FileState.DIRTY); editor.refresh(); } } // Preserve settings if (panel.getEndLineCombo().getSelectedItem() != null) { panel.setLastSelectedLineEndStyle((LineEdgeType) panel.getEndLineCombo().getSelectedItem()); } } }); }
From source file:org.pmedv.blackboard.commands.ShowLayersCommand.java
private void initListeners() { layerPanel.getCurrentLayerCombo().addActionListener(new ActionListener() { @Override//www . ja v a 2 s. co m public void actionPerformed(ActionEvent e) { if (editor != null) { Layer currentLayer = (Layer) layerPanel.getCurrentLayerCombo().getSelectedItem(); log.info("setting current layer to : " + layerPanel.getCurrentLayerCombo().getSelectedItem()); editor.getModel().setCurrentLayer(currentLayer); int opacity = (int) (editor.getModel().getCurrentLayer().getOpacity() * 100); layerPanel.getOpacitySlider().setValue(opacity); } } }); layerPanel.getAddLayerButton().setAction(AppContext.getContext().getBean(AddLayerCommand.class)); layerPanel.getRemoveLayerButton().setAction(AppContext.getContext().getBean(DeleteLayerCommand.class)); layerPanel.getOpacitySlider().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); float opacity = (float) slider.getValue() / 100.0f; editor.getModel().getCurrentLayer().setOpacity(opacity); editor.repaint(); // TODO : Happens also if an editor changes, what should we do? // editor.setFileState(FileState.DIRTY); } }); }
From source file:org.pmedv.blackboard.dialogs.PartDialog.java
@Override protected void initializeComponents() { partPanel = new PartPanel(); partBusyPanel = new JBusyComponent<PartPanel>(partPanel); setSize(new Dimension(900, 750)); textArea = new RSyntaxTextArea(); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML); RTextScrollPane textScrollPane = new RTextScrollPane(textArea); CompletionProvider provider = createCompletionProvider(); AutoCompletion ac = new AutoCompletion(provider); ac.install(textArea);/*w ww . j a v a2s . c o m*/ JPopupMenu popup = textArea.getPopupMenu(); popup.addSeparator(); popup.add(new JMenuItem(new SaveAction())); tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM); tabbedPane.addTab("Parts", partBusyPanel); tabbedPane.addTab("Part Editor", textScrollPane); tabbedPane.setEnabledAt(1, false); getContentPanel().add(tabbedPane); tablePopupMenu = new JPopupMenu(); // We do the part loading in background and display a busy panel while loading SwingWorker<ArrayList<Part>, Void> w = new SwingWorker<ArrayList<Part>, Void>() { @Override protected ArrayList<Part> doInBackground() { partBusyPanel.setBusy(true); try { return AppContext.getContext().getBean(PartFactory.class).getAvailableParts(); } catch (Exception e) { ErrorUtils.showErrorDialog(e); return new ArrayList<Part>(); } } @Override protected void done() { log.info("Done loading parts."); try { model = new PartTableModel(get()); partPanel.getPartTable().setModel(model); } catch (Exception e) { ErrorUtils.showErrorDialog(e); } partBusyPanel.setBusy(false); partPanel.transferFocus(); } }; getOkButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JXTable table = partPanel.getPartTable(); result = OPTION_OK; selectedParts = new ArrayList<Part>(); int rows[] = partPanel.getPartTable().getSelectedRows(); try { for (int i = 0; i < rows.length; i++) { selectedParts.add(AppContext.getContext().getBean(PartFactory.class).createPart( model.getParts().get(table.convertRowIndexToModel(rows[i])).getFilename())); } } catch (Exception e1) { ErrorUtils.showErrorDialog(e1); } setVisible(false); } }); getCancelButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { result = OPTION_CANCEL; setVisible(false); } }); getNewButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AppContext.getContext().getBean(CreatePartCommand.class).execute(e); } }); partPanel.getPartTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { JXTable table = partPanel.getPartTable(); int[] rows = table.getSelectedRows(); if (rows.length == 1) { if (model == null) return; Part selectedPart = model.getParts().get(table.convertRowIndexToModel(rows[0])); currentPart = selectedPart; selectedRow = table.convertRowIndexToModel(rows[0]); partPanel.getImageLabel().setIcon(new ImageIcon(selectedPart.getImage())); partPanel.getImageLabel().setText(null); partPanel.getPartNameField().setText(selectedPart.getName()); partPanel.getDescriptionPane().setText(selectedPart.getDescription()); partPanel.getPackageTypeField().setText(selectedPart.getPackageType()); partPanel.getAuthorField().setText(selectedPart.getAuthor()); partPanel.getLicenseField().setText(selectedPart.getLicense()); tabbedPane.setEnabledAt(1, true); textArea.setText(selectedPart.getXmlContent()); } else { currentPart = null; partPanel.getImageLabel().setText(resources.getResourceByKey("PartDialog.selectmsg")); partPanel.getImageLabel().setIcon(null); tabbedPane.setEnabledAt(1, false); textArea.setText(""); } } }); tabbedPane.addChangeListener(new ChangeListener() { // This method is called whenever the selected tab changes public void stateChanged(ChangeEvent evt) { JTabbedPane pane = (JTabbedPane) evt.getSource(); int index = pane.getSelectedIndex(); if (index == 0) { getTitleLabel().setText(title); getSubTitleLabel().setText(subTitle); } else { getTitleLabel().setText(editTitle); getSubTitleLabel().setText(editSubTitle + " : " + currentPart.getName()); } } }); partPanel.getPartTable().addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { handlePopupTrigger(e); } @Override public void mouseReleased(MouseEvent e) { handlePopupTrigger(e); } }); tablePopupMenu.add(ctx.getBean(DeletePartCommand.class)); // this is the filter configuration for the filter text box on the top PartFilter filter = new PartFilter(partPanel.getPartTable()); BindingGroup filterGroup = new BindingGroup(); // bind filter JTextBox's text attribute to part tables filterString // attribute filterGroup.addBinding(Bindings.createAutoBinding(READ, partPanel.getFilterPanel().getFilterTextField(), BeanProperty.create("text"), filter, BeanProperty.create("filterString"))); filterGroup.bind(); w.execute(); }