List of usage examples for javax.swing.event ChangeEvent getSource
public Object getSource()
From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java
/** * Main visualizer setup./* w w w . j a v a 2 s.c om*/ */ private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) this.setLayout(new BorderLayout()); // MAIN PANEL JPanel mainPanel = new JPanel(); Border margin = new EmptyBorder(10, 10, 5, 10); Border margin2 = new EmptyBorder(10, 10, 5, 10); mainPanel.setBorder(margin); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(makeTitlePanel()); myJTable = new JTable(model); JMeterUtils.applyHiDPI(myJTable); // Fix centering of titles myJTable.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer(COLUMNS_MSG_PARAMETERS)); myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70)); RendererUtils.applyRenderers(myJTable, RENDERERS); myScrollPane = new JScrollPane(myJTable); settingsPane = new VerticalPanel(); settingsPane.setBorder(margin2); graphPanel = new AxisGraph(); graphPanel.setPreferredSize(new Dimension(defaultWidth, defaultHeight)); settingsPane.add(createGraphActionsPane()); settingsPane.add(createGraphColumnPane()); settingsPane.add(createGraphTitlePane()); settingsPane.add(createGraphDimensionPane()); JPanel axisPane = new JPanel(new BorderLayout()); axisPane.add(createGraphXAxisPane(), BorderLayout.WEST); axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER); settingsPane.add(axisPane); settingsPane.add(createLegendPane()); tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane); //$NON-NLS-1$ tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel); //$NON-NLS-1$ // If clic on the Graph tab, make the graph (without apply interval or filter) ChangeListener changeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent changeEvent) { JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource(); int index = srcTab.getSelectedIndex(); if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) { //$NON-NLS-1$ actionMakeGraph(); } } }; tabbedGraph.addChangeListener(changeListener); spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); spane.setLeftComponent(myScrollPane); spane.setRightComponent(tabbedGraph); spane.setResizeWeight(.2); spane.setBorder(null); // see bug jdk 4131528 spane.setContinuousLayout(true); this.add(mainPanel, BorderLayout.NORTH); this.add(spane, BorderLayout.CENTER); }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java
private JPanel getPriorityPanel(final ViewState state) { JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder()); panel.setLayout(new BorderLayout()); panel.add(new JLabel("Priority: "), BorderLayout.WEST); final JLabel priorityLabel = new JLabel(String.valueOf(DEFAULT_PRIORITY)); panel.add(priorityLabel, BorderLayout.CENTER); JSlider slider = new JSlider(0, 100, (int) 5 * 10); slider.setMajorTickSpacing(10);//w w w. ja v a 2 s. c om slider.setMinorTickSpacing(1); slider.setPaintLabels(true); slider.setPaintTicks(true); slider.setSnapToTicks(false); Format f = new DecimalFormat("0.0"); Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>(); for (int i = 0; i <= 10; i += 2) { JLabel label = new JLabel(f.format(i)); label.setFont(label.getFont().deriveFont(Font.PLAIN)); labels.put(i * 10, label); } slider.setLabelTable(labels); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double value = ((JSlider) e.getSource()).getValue() / 10.0; priorityLabel.setText(value + ""); priorityLabel.revalidate(); if (!((JSlider) e.getSource()).getValueIsAdjusting()) { // FIXME: deal with priorities DefaultPropView.this.notifyListeners(); } } }); panel.add(slider, BorderLayout.SOUTH); return panel; }
From source file:org.ayound.js.debug.ui.DebugMainFrame.java
private Component createMainPane() { mainPane = new CloseableTabbedPane(); mainPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // TODO Auto-generated method stub Object source = e.getSource(); if (source instanceof JTabbedPane) { JTabbedPane pane = (JTabbedPane) source; int index = pane.getSelectedIndex(); if (index > -1) { String tips = pane.getToolTipTextAt(index); DebugUIUtil.setCurrentFile(tips); }//from w w w.j a va 2 s . c o m } } }); BookMarkListenerManager.setListener(new IBookMarkListener() { public boolean beforeAddBookmark(int line) { // if (EngineManager.getEngine().canBreakLine( // DebugUIUtil.getCurrentFile(), line + 1)) { // BreakPointManager.addBreakPoint(DebugUIUtil // .getCurrentFile(), line); // return true; // } else { // return false; // } BreakPointManager.addBreakPoint(DebugUIUtil.getCurrentFile(), line); return true; } public boolean beforeRemoveBookmark(int line) { BreakPointManager.removeBreakPoint(DebugUIUtil.getCurrentFile(), line, true); return true; } }); return mainPane; }
From source file:org.bibsonomy.plugin.jabref.listener.TabbedPaneChangeListener.java
public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { JTabbedPane pane = (JTabbedPane) e.getSource(); Component[] components = pane.getComponents(); for (Component c : components) { BasePanel bp = (BasePanel) c; if (bp.database() != null) { bp.database().addDatabaseChangeListener(databaseChangeListener); } else { log.warn("found tab-component without database"); }/* w ww . j a v a 2 s . c o m*/ } if (components.length == 0) { log.info("pane has no tab-components"); } } }
From source file:org.esa.s1tbx.ocean.worldwind.layers.Level2ProductLayer.java
public JPanel getControlPanel(final WorldWindowGLCanvas wwd) { theControlLevel2Panel = new JPanel(new GridLayout(7, 1, 5, 5)); theControlLevel2Panel.setVisible(false); final JRadioButton owiBtn = new JRadioButton("OWI"); owiBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { theSelectedComp = "owi"; setComponentVisible("owi", wwd); theArrowsCB.setEnabled(true); }//w ww . j a va 2 s . co m }); final JRadioButton oswBtn = new JRadioButton("OSW"); oswBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { theSelectedComp = "osw"; setComponentVisible("osw", wwd); theArrowsCB.setEnabled(false); //SystemUtils.LOG.info("theSurfaceProductHash " + theSurfaceProductHash); //SystemUtils.LOG.info("theSurfaceSequenceHash " + theSurfaceSequenceHash); } }); final JRadioButton rvlBtn = new JRadioButton("RVL"); rvlBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { theSelectedComp = "rvl"; //System.out.println("rvl:"); //setComponentVisible("owi", false, getWwd()); //setComponentVisible("osw", false, getWwd()); setComponentVisible("rvl", wwd); theArrowsCB.setEnabled(false); } }); final ButtonGroup group = new ButtonGroup(); group.add(owiBtn); group.add(oswBtn); group.add(rvlBtn); owiBtn.setSelected(true); theSelectedComp = "owi"; final JPanel componentTypePanel = new JPanel(new GridLayout(1, 4, 5, 5)); componentTypePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); componentTypePanel.add(new JLabel("Component:")); componentTypePanel.add(owiBtn); componentTypePanel.add(oswBtn); componentTypePanel.add(rvlBtn); theControlLevel2Panel.add(componentTypePanel); final JPanel arrowDisplayPanel = new JPanel(new GridLayout(1, 2, 5, 5)); theArrowsCB = new JCheckBox(new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { // Simply enable or disable the layer based on its toggle button. if (((JCheckBox) actionEvent.getSource()).isSelected()) theOWIArrowsDisplayed = true; else theOWIArrowsDisplayed = false; wwd.redrawNow(); } }); arrowDisplayPanel.add(new JLabel("Display Wind Vectors:")); arrowDisplayPanel.add(theArrowsCB); theControlLevel2Panel.add(arrowDisplayPanel); /* final JPanel subsectionPanel = new JPanel(new GridLayout(1, 2, 5, 5)); JComboBox sectionDropDown = new JComboBox(); sectionDropDown.addItem("001"); sectionDropDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SystemUtils.LOG.info("drop down changed"); } }); subsectionPanel.add(new JLabel("Subsection:")); subsectionPanel.add(sectionDropDown); theControlLevel2Panel.add(subsectionPanel); */ final JPanel maxPanel = new JPanel(new GridLayout(1, 2, 5, 5)); maxPanel.add(new JLabel("Max OWI Wind Speed:")); final JSpinner maxSP = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1)); maxSP.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int newValue = (Integer) ((JSpinner) e.getSource()).getValue(); theOWILimitChanged = true; } }); maxPanel.add(maxSP); theControlLevel2Panel.add(maxPanel); final JPanel minPanel = new JPanel(new GridLayout(1, 2, 5, 5)); minPanel.add(new JLabel("Min OWI Wind Speed:")); final JSpinner minSP = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1)); minSP.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { theOWILimitChanged = true; } }); minPanel.add(minSP); theControlLevel2Panel.add(minPanel); final JPanel maxRVLPanel = new JPanel(new GridLayout(1, 2, 5, 5)); maxRVLPanel.add(new JLabel("Max RVL Rad Vel.:")); final JSpinner maxRVLSP = new JSpinner(new SpinnerNumberModel(6, 0, 10, 1)); maxRVLSP.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int newValue = (Integer) ((JSpinner) e.getSource()).getValue(); theRVLLimitChanged = true; } }); maxRVLPanel.add(maxRVLSP); theControlLevel2Panel.add(maxRVLPanel); final JButton updateButton = new JButton("Update"); updateButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (theOWILimitChanged) { //double minValue = ((Integer) minSP.getValue()) * 1.0e4; //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4; double minValue = ((Integer) minSP.getValue()); double maxValue = ((Integer) maxSP.getValue()); recreateColorBarAndGradient(minValue, maxValue, "owi", wwd, theSelectedComp.equalsIgnoreCase("owi")); } if (theRVLLimitChanged) { //SystemUtils.LOG.info("theRVLLimitChanged"); //double minValue = ((Integer) minSP.getValue()) * 1.0e4; //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4; double maxValue = ((Integer) maxRVLSP.getValue()); double minValue = -1 * maxValue; recreateColorBarAndGradient(minValue, maxValue, "rvl", wwd, theSelectedComp.equalsIgnoreCase("rvl")); } theOWILimitChanged = false; theRVLLimitChanged = false; } }); theControlLevel2Panel.add(updateButton); createColorBarLegend(0, 10, "OWI Wind Speed", "owi"); createColorBarLegend(0, 10, "OSW Wave Height.", "osw"); createColorBarLegend(-6, 6, "RVL Rad. Vel.", "rvl"); //addRenderable(theColorBarLegendHash.get("owi")); return theControlLevel2Panel; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java
public void stateChanged(ChangeEvent e) { if (e.getSource().equals(tabbedPane)) { loginMode = tabbedPane.getSelectedIndex(); changedLoginMode();// w ww .j a va 2s . c o m } }
From source file:org.freeplane.core.resources.components.OptionPanel.java
/** * This method builds the preferences panel. * A list of IPropertyControl is iterated through and * if the IPropertyControl is an instance of TabProperty, * it creates a new "tab" that can be clicked to reveal the appropriate panel. * If the previous selected tab was saved on close, * the appropriate tab is reopened./*from w w w . j a v a 2s . com*/ * * @param controlsTree This is the data that needs to be built */ public void buildPanel(final DefaultMutableTreeNode controlsTree) { final JPanel centralPanel = new JPanel(); centralPanel.setLayout(new GridLayout(1, 1)); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); FormLayout bottomLayout = null; DefaultFormBuilder bottomBuilder = null; initControls(controlsTree); final Iterator<IPropertyControl> iterator = controls.iterator(); int tabIndex = 0; while (iterator.hasNext()) { final IPropertyControl control = iterator.next(); if (control instanceof TabProperty) { final TabProperty newTab = (TabProperty) control; bottomLayout = new FormLayout(newTab.getName(), ""); bottomBuilder = new DefaultFormBuilder(bottomLayout); bottomBuilder.setDefaultDialogBorder(); final JScrollPane bottomComponent = new JScrollPane(bottomBuilder.getPanel()); UITools.setScrollbarIncrement(bottomComponent); final String tabName = TextUtils.getOptionalText(newTab.getLabel()); tabStringToIndexMap.put(tabName, tabIndex); tabIndexToStringMap.put(tabIndex, tabName); tabbedPane.addTab(tabName, bottomComponent); tabIndex++; } else { control.layout(bottomBuilder); } } tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent event) { final JTabbedPane c = (JTabbedPane) event.getSource(); selectedPanel = tabIndexToStringMap.get(c.getSelectedIndex()); } }); centralPanel.add(tabbedPane); if (selectedPanel != null && tabStringToIndexMap.containsKey(selectedPanel)) { // Without the containsKey call the loading of the tab "behaviour"/"behavior" gives a nullpointer exception tabbedPane.setSelectedIndex(tabStringToIndexMap.get(selectedPanel)); } topDialog.getContentPane().add(centralPanel, BorderLayout.CENTER); final JButton cancelButton = new JButton(); MenuBuilder.setLabelAndMnemonic(cancelButton, TextUtils.getRawText("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { closeWindow(); } }); final JButton okButton = new JButton(); MenuBuilder.setLabelAndMnemonic(okButton, TextUtils.getRawText("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (validate()) { closeWindow(); feedback.writeProperties(getOptionProperties()); } } }); topDialog.getRootPane().setDefaultButton(okButton); topDialog.getContentPane().add(ButtonBarFactory.buildOKCancelBar(cancelButton, okButton), BorderLayout.SOUTH); }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importFile(FileObject fileObject) { try {//from w w w . j a v a 2s.co m final FileImporter importer = controller.getFileImporter(FileUtil.toFile(fileObject)); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } //MRU MostRecentFiles mostRecentFiles = Lookup.getDefault().lookup(MostRecentFiles.class); mostRecentFiles.addFile(fileObject.getPath()); ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task fileObject = getArchivedFile(fileObject); final String containerSource = fileObject.getNameExt(); final InputStream stream = fileObject.getInputStream(); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(stream, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); if (fileObject.getPath().startsWith(System.getProperty("java.io.tmpdir"))) { try { fileObject.delete(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importStream(final InputStream stream, String importerName) { try {/*from w w w . j ava 2 s . c om*/ final FileImporter importer = controller.getFileImporter(importerName); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.streamSource", importerName); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(stream, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importFile(final Reader reader, String importerName) { try {/* w ww . j av a2 s .c o m*/ final FileImporter importer = controller.getFileImporter(importerName); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } ImporterUI ui = controller.getUI(importer); if (ui != null) { ui.setup(importer); String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.streamSource", importerName); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(reader, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }