List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:com.diversityarrays.kdxplore.design.SheetChooserPanel.java
public SheetChooserPanel(BackgroundRunner br, Consumer<String> onSheetChosen /*, Component ... more */) { super(new BorderLayout()); this.backgroundRunner = br; this.onChoice = onSheetChosen; sheetComboBox.addActionListener(new ActionListener() { @Override//from ww w . j a v a 2 s. co m public void actionPerformed(ActionEvent e) { Object item = sheetComboBox.getSelectedItem(); if (item == null) { selectedSheetName = null; } else { selectedSheetName = sheetComboBox.getSelectedItem().toString(); } updateUsingSelected(); } }); spinnerModel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateUsingSelected(); } }); GuiUtil.setVisibleRowCount(dataPreviewTable, DEFAULT_VISIBLE_ROWCOUNT); Box top = Box.createHorizontalBox(); top.add(new JLabel("Select Sheet: ")); top.add(sheetComboBox); top.add(Box.createHorizontalGlue()); top.add(new JLabel("Preview:")); top.add(new JSpinner(spinnerModel)); top.add(Box.createHorizontalGlue()); top.add(new JButton(useAction)); // if (more != null) { // for (Component c : more) { // top.add(c); // } // } add(top, BorderLayout.NORTH); add(dataPreviewScrollPane, BorderLayout.CENTER); useAction.setEnabled(false); }
From source file:com.t3.client.ui.AddResourceDialog.java
public void initTabPane() { final JTabbedPane tabPane = (JTabbedPane) getComponent("tabPane"); tabPane.getModel().addChangeListener(new ChangeListener() { @Override//from w w w. j av a 2s . com public void stateChanged(ChangeEvent e) { // Hmmm, this is fragile (breaks if the order changes) rethink this later switch (tabPane.getSelectedIndex()) { case 0: model.tab = Tab.LOCAL; break; case 1: model.tab = Tab.WEB; break; case 2: model.tab = Tab.TABLETOPTOOL_SITE; downloadLibraryList(); break; } } }); }
From source file:mulavito.gui.components.GraphPanel.java
protected GraphPanel() { super(new BorderLayout()); layout = new MyGridLayout(1, 1); contentPane = new JPanel(); add(contentPane);//from w w w. j a va 2s .co m contentPane.setLayout(layout); vvs = new LinkedList<LV>(); verticalScrollBar = new JScrollBar(JScrollBar.VERTICAL); verticalScrollBar.setValues(0, 0, 0, 0); add(verticalScrollBar, BorderLayout.EAST); horizontalScrollBar = new JScrollBar(JScrollBar.HORIZONTAL); horizontalScrollBar.setValues(0, 0, 0, 0); south = new JPanel(new BorderLayout()); south.add(horizontalScrollBar); add(south, BorderLayout.SOUTH); setCorner(new SatelliteMultiViewerCorner()); // for layer stack stackListener = new ChangeListener() { @SuppressWarnings("unchecked") @Override public void stateChanged(ChangeEvent e) { // handle layer change if (e instanceof LayerChangedEvent<?>) { LayerChangedEvent<L> lce = (LayerChangedEvent<L>) e; if (lce.remove) { if (lce.g != null)// remove layer removeLayer(getViewer(lce.g)); else // clear layers while (vvs.size() > 0) removeLayer(vvs.get(0)); } else if (lce.g != null) // add layer addLayer(lce.g); javax.swing.SwingUtilities.invokeLater(new Runnable() { // To ensure correct behavior when several layers are // added at the same time, we slightly delay these // calls. @Override public void run() { configureScrollBars(); configureSpinner(); arrangeViewers(); autoZoomToFit(); } }); } // else removed vertices updateUI(); } }; // configure contexts contexts = new LinkedList<ViewerContext<L, LV>>(); // addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { arrangeViewers(); autoZoomToFit(); } }); }
From source file:net.rptools.maptool.client.ui.AddResourceDialog.java
public void initTabPane() { final JTabbedPane tabPane = (JTabbedPane) getComponent("tabPane"); tabPane.getModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // Hmmm, this is fragile (breaks if the order changes) rethink this later switch (tabPane.getSelectedIndex()) { case 0: model.tab = Tab.LOCAL;/*from w ww . java 2 s . c om*/ break; case 1: model.tab = Tab.WEB; break; case 2: model.tab = Tab.RPTOOLS; downloadLibraryList(); break; } } }); }
From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { Box ret = new Box(BoxLayout.X_AXIS); ret.add(new JLabel("k:")); final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1)); spin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setK(((Number) spin.getValue()).intValue()); v.settingsChanged(false);//from w w w .j av a2s. c o m } }); ret.add(spin); final JCheckBox showClustersBox = new JCheckBox("Color clusters"); ret.add(showClustersBox); showClustersBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { showClusters = showClustersBox.isSelected(); v.settingsChanged(false); } }); return ret; }
From source file:com.hazelcast.simulator.visualiser.ui.Chart.java
private void initSliderChangeListener() { mainHorizontalSlider.addChangeListener(new ChangeListener() { @Override/*from w w w . j av a2 s . co m*/ public void stateChanged(ChangeEvent e) { int value = mainHorizontalSlider.getValue(); plot.getDomainAxis().setUpperBound(value); plot.getDomainAxis().setLowerBound(0); fineHorizontalSlider.setMaximum(value); fineHorizontalSlider.setValue(value); } }); fineHorizontalSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int value = fineHorizontalSlider.getValue(); plot.getDomainAxis().setUpperBound(value); plot.getDomainAxis().setLowerBound(0); } }); verticalSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { plot.getRangeAxis().setUpperBound(verticalSlider.getValue()); plot.getRangeAxis().setLowerBound(0); } }); addHorizontalMouseListener(this, mainHorizontalSlider); addHorizontalMouseListener(this, fineHorizontalSlider); addVerticalMouseListener(this, verticalSlider); }
From source file:de.tor.tribes.ui.views.DSWorkbenchMarkerFrame.java
/** Creates new form DSWorkbenchMarkerFrame */ DSWorkbenchMarkerFrame() {/*ww w . ja v a2 s . com*/ initComponents(); if (!GlobalOptions.isMinimal()) { centerPanel = new GenericTestPanel(true); } else { centerPanel = new GenericTestPanel(false); } jMarkersPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jXMarkerPanel); if (!GlobalOptions.isMinimal()) { buildMenu(); } capabilityInfoPanel1.addActionListener(this); jMarkerTabPane.getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { MarkerTableTab activeTab = getActiveTab(); if (activeTab != null) { activeTab.updateSet(); } } }); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.markers_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> pack(); }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.DendogramView.java
/** * @param t// w w w . j a v a 2 s. c o m * @param numClusters2 */ public void update(ClusteringTree t, int numClusters) { frame.setVisible(true); frame.getContentPane().removeAll(); try { // create spinner-panel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters"); spinnerCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1)); spinnerCluster.setValue(numClusters); spinnerCluster.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (mMainSpinnerCluster != null) { mMainSpinnerCluster.setValue(((JSpinner) e.getSource()).getValue()); } } }); UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerCluster); frame.getContentPane().add(clusterPanel, BorderLayout.NORTH); // create graph VisualizationViewer g = generateGraph(t, numClusters); frame.getContentPane().add(g, BorderLayout.CENTER); frame.setSize(frame.getWidth() + 1, frame.getHeight() + 1); frame.setSize(frame.getWidth() - 1, frame.getHeight() - 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.joey.software.MoorFLSI.RepeatImageTextReader.java
public void createJPanel() { setLayout(new BorderLayout()); add(currentValue, BorderLayout.NORTH); add(image, BorderLayout.CENTER); currentValue.addChangeListener(new ChangeListener() { @Override/* ww w .ja va 2 s . c o m*/ public void stateChanged(ChangeEvent e) { setCurrentImage((Integer) currentValue.getValue()); } }); // Create the text output panel JPanel outputPanel = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(dataField); outputPanel.add(scrollPane, BorderLayout.CENTER); JTabbedPane tabPanel = new JTabbedPane(); tabPanel.addTab("Graph", chartPanel); tabPanel.addTab("Data", outputPanel); staticsHolderFrame.getContentPane().setLayout(new BorderLayout()); staticsHolderFrame.getContentPane().removeAll(); staticsHolderFrame.getContentPane().add(tabPanel, BorderLayout.CENTER); staticsHolderFrame.getContentPane().add(outputImages, BorderLayout.SOUTH); // Add region panel to image image.getImage().setControler(ROIPanel.TYPE_RECTANGLE); image.getImage().setAllowMultipleROI(false); image.getImage().addROIPanelListner(new ROIPanelListner() { @Override public void regionAdded(Shape region) { updateData(); } @Override public void regionChanged() { // TODO Auto-generated method stub } @Override public void regionRemoved(Shape region) { // TODO Auto-generated method stub } }); outputImages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImages(); } }); }
From source file:FontPicker.java
public FontChooser(Frame parent) { super(parent, "Font Chooser", true); setSize(450, 450);//from www . ja v a2 s.co m attributes = new SimpleAttributeSet(); // Make sure that any way the user cancels the window does the right // thing addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { closeAndCancel(); } }); // Start the long process of setting up our interface Container c = getContentPane(); JPanel fontPanel = new JPanel(); fontName = new JComboBox(new String[] { "TimesRoman", "Helvetica", "Courier" }); fontName.setSelectedIndex(1); fontName.addActionListener(this); fontSize = new JTextField("12", 4); fontSize.setHorizontalAlignment(SwingConstants.RIGHT); fontSize.addActionListener(this); fontBold = new JCheckBox("Bold"); fontBold.setSelected(true); fontBold.addActionListener(this); fontItalic = new JCheckBox("Italic"); fontItalic.addActionListener(this); fontPanel.add(fontName); fontPanel.add(new JLabel(" Size: ")); fontPanel.add(fontSize); fontPanel.add(fontBold); fontPanel.add(fontItalic); c.add(fontPanel, BorderLayout.NORTH); // Set up the color chooser panel and attach a change listener so that // color // updates get reflected in our preview label. colorChooser = new JColorChooser(Color.black); colorChooser.getSelectionModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { updatePreviewColor(); } }); c.add(colorChooser, BorderLayout.CENTER); JPanel previewPanel = new JPanel(new BorderLayout()); previewLabel = new JLabel("Here's a sample of this font."); previewLabel.setForeground(colorChooser.getColor()); previewPanel.add(previewLabel, BorderLayout.CENTER); // Add in the Ok and Cancel buttons for our dialog box JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { closeAndSave(); } }); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { closeAndCancel(); } }); JPanel controlPanel = new JPanel(); controlPanel.add(okButton); controlPanel.add(cancelButton); previewPanel.add(controlPanel, BorderLayout.SOUTH); // Give the preview label room to grow. previewPanel.setMinimumSize(new Dimension(100, 100)); previewPanel.setPreferredSize(new Dimension(100, 100)); c.add(previewPanel, BorderLayout.SOUTH); }