List of usage examples for javax.swing.event ChangeEvent getSource
public Object getSource()
From source file:org.openmicroscopy.shoola.agents.metadata.view.MetadataViewerFactory.java
/** * Removes a viewer from the {@link #viewers} set when it is * {@link MetadataViewer#DISCARDED discarded}. * @see ChangeListener#stateChanged(ChangeEvent) *///from www . j av a2s . c o m public void stateChanged(ChangeEvent e) { MetadataViewerComponent comp = (MetadataViewerComponent) e.getSource(); if (comp.getState() == MetadataViewer.DISCARDED && viewers.size() > 0) viewers.remove(comp); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.actions.TreeViewerAction.java
/** * Reacts to state changes in the {@link Browser}. * @see ChangeListener#stateChanged(ChangeEvent) *//* w w w . j a v a2 s . co m*/ public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof Browser) onBrowserStateChange((Browser) source); }
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.//w w w.ja v a2 s . c om * * @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.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerFactory.java
/** * Sets the {@link #viewer} to <code>null</code> when it is * {@link TreeViewer#DISCARDED discarded}. * @see ChangeListener#stateChanged(ChangeEvent) *///from w w w.j a v a 2 s.com public void stateChanged(ChangeEvent ce) { TreeViewerComponent comp = (TreeViewerComponent) ce.getSource(); if (comp.getState() == TreeViewer.DISCARDED) viewers.remove(comp); }
From source file:org.paxle.desktop.impl.event.MultipleChangesListener.java
public void stateChanged(ChangeEvent e) { setState(e.getSource(), System.currentTimeMillis()); }
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 . ja v a 2 s. 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(); }
From source file:org.sikuli.ide.SikuliIDE.java
private JComponent createCommandPane() { JXTaskPaneContainer con = new JXTaskPaneContainer(); PreferencesUser pref = PreferencesUser.getInstance(); JCheckBox chkAutoCapture = new JCheckBox(_I("cmdListAutoCapture"), pref.getAutoCaptureForCmdButtons()); chkAutoCapture.addChangeListener(new ChangeListener() { @Override//w w w .j a va 2 s. c om public void stateChanged(javax.swing.event.ChangeEvent e) { boolean flag = ((JCheckBox) e.getSource()).isSelected(); PreferencesUser pref = PreferencesUser.getInstance(); pref.setAutoCaptureForCmdButtons(flag); } }); JXTaskPane setPane = new JXTaskPane(); setPane.setTitle(_I("cmdListSettings")); setPane.add(chkAutoCapture); setPane.setCollapsed(true); con.add(setPane); int cat = 0; JXTaskPane taskPane = new JXTaskPane(); taskPane.setTitle(getCommandCategories()[cat++]); con.add(taskPane); String[][] CommandsOnToolbar = getCommandsOnToolbar(); boolean collapsed; for (int i = 0; i < CommandsOnToolbar.length; i++) { String cmd = CommandsOnToolbar[i++][0]; String[] params = CommandsOnToolbar[i++]; String[] desc = CommandsOnToolbar[i]; //TODO: more elegeant way, to handle special cases if (cmd.equals("----")) { if (cat == 2) { collapsed = true; } else { collapsed = false; } if (cat == 3) { if (prefs.getUserType() == PreferencesUser.NEWBEE) { break; } else { collapsed = true; } } taskPane = new JXTaskPane(); taskPane.setTitle(getCommandCategories()[cat++]); con.add(taskPane); taskPane.setCollapsed(collapsed); } else { taskPane.add(new ButtonGenCommand(cmd, desc[0], params)); } } Dimension conDim = con.getSize(); con.setPreferredSize(new Dimension(250, 1000)); _cmdList = new JXCollapsiblePane(JXCollapsiblePane.Direction.LEFT); _cmdList.setMinimumSize(new Dimension(0, 0)); _cmdList.add(new JScrollPane(con)); _cmdList.setCollapsed(false); return _cmdList; }
From source file:org.spiderplan.tools.visulization.GraphFrame.java
@Override public void stateChanged(ChangeEvent arg0) { if (arg0.getSource() instanceof JSlider) { JSlider source = (JSlider) arg0.getSource(); // if ( !source.getValueIsAdjusting() ) { int newHistoryIndex = source.getValue(); if (newHistoryIndex == historyIndex) { return; }// w ww . j a va2 s . co m historyIndex = newHistoryIndex; AbstractTypedGraph<V, E> H = this.history.get(historyIndex); Vector<E> removeList = new Vector<E>(); for (E e : this.g.getEdges()) { if (!H.containsEdge(e)) { removeList.add(e); } } for (E e : removeList) { this.g.removeEdge(e); } Vector<V> removeVertexList = new Vector<V>(); for (V v : this.g.getVertices()) { if (!H.containsVertex(v)) { removeVertexList.add(v); } } for (V v : removeVertexList) { this.g.removeVertex(v); } for (E e : H.getEdges()) { if (!this.g.containsEdge(e)) { this.g.addEdge(e, H.getEndpoints(e).getFirst(), H.getEndpoints(e).getSecond()); } } for (V v : H.getVertices()) { if (!this.g.containsVertex(v)) { this.g.addVertex(v); } } // } } }
From source file:org.yccheok.jstock.gui.AboutJDialog.java
private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged JTabbedPane pane = (JTabbedPane) evt.getSource(); if (pane.getSelectedComponent() == this.jPanel6) { // Have blob sallad to grab the focus. controller.requestFocus();//from w w w . j av a2 s .com } }
From source file:org.yccheok.jstock.gui.JStock.java
private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged // TODO add your handling code here: JTabbedPane pane = (JTabbedPane) evt.getSource(); handleJTabbedPaneStateChanged(pane); }