List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:bazaar4idea.ui.BzrPushDialog.java
public BzrPushDialog(Project project) { super(project, false); this.project = project; hgRepositorySelectorComponent.setTitle("Select repository to push from"); hgRepositorySelectorComponent.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateRepository();/*from ww w.ja v a2s .com*/ } }); revisionCbx.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { update(); } }); DocumentListener documentListener = new DocumentListener() { public void insertUpdate(DocumentEvent e) { update(); } public void removeUpdate(DocumentEvent e) { update(); } public void changedUpdate(DocumentEvent e) { update(); } }; repositoryTxt.getDocument().addDocumentListener(documentListener); revisionTxt.getDocument().addDocumentListener(documentListener); setTitle("Push"); init(); }
From source file:House.java
public House() { super(new BorderLayout()); JPanel controlPanel = new JPanel(new GridLayout(3, 3)); add(controlPanel, BorderLayout.NORTH); controlPanel.add(new JLabel("Translate(dx,dy): ")); sliderTransX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50); sliderTransY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50); // To control rotation controlPanel.add(new JLabel("Rotate(Theta,ox,oy): ")); sliderRotateTheta = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 360, 0, 90, 45); JPanel subPanel = new JPanel(); subPanel.setLayout(new GridLayout(1, 2)); sliderRotateX = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50); sliderRotateY = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50); controlPanel.add(subPanel);// w w w . j a v a 2 s . c o m // To control scaling controlPanel.add(new JLabel("Scale(sx,sy)x10E-2:")); sliderScaleX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10); sliderScaleY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10); // To control width of line segments JLabel label4 = new JLabel("Width Control:", JLabel.RIGHT); sliderWidth = new JSlider(JSlider.HORIZONTAL, 0, 20, 1); sliderWidth.setPaintTicks(true); sliderWidth.setMajorTickSpacing(5); sliderWidth.setMinorTickSpacing(1); sliderWidth.setPaintLabels(true); sliderWidth.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { width = sliderWidth.getValue(); canvas.repaint(); } }); JPanel widthPanel = new JPanel(); widthPanel.setLayout(new GridLayout(1, 2)); widthPanel.add(label4); widthPanel.add(sliderWidth); add(widthPanel, BorderLayout.SOUTH); canvas = new MyCanvas(); add(canvas, "Center"); }
From source file:compecon.dashboard.panel.StatesPanel.java
public StatesPanel() { this.setLayout(new BorderLayout()); for (Currency currency : Currency.values()) { JPanel panelForCurrency = new StatePanelForCurrency(currency); jTabbedPaneCurrency.addTab(currency.getIso4217Code(), panelForCurrency); }/*from w ww . java2 s. c o m*/ jTabbedPaneCurrency.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { JTabbedPane pane = (JTabbedPane) e.getSource(); StatePanelForCurrency selectedComponent = (StatePanelForCurrency) pane.getSelectedComponent(); selectedComponent.notifyListener(); } } }); add(jTabbedPaneCurrency, BorderLayout.CENTER); }
From source file:SourceInDemo.java
public SourceInDemo() { super("Source In"); add(new ImageViewer(), BorderLayout.CENTER); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING)); panel.add(shadow = new JCheckBox("Drop Shadow")); shadow.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { repaint();//from w ww .j av a 2 s . co m } }); add(panel, BorderLayout.SOUTH); setSize(350, 250); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:hr.fer.zemris.vhdllab.platform.support.SimplisticEclipseBasedApplicationPage.java
@Override protected JComponent createControl() { projectExplorerPane = new JPanel(new BorderLayout()); editorsPane = new JPanel(new BorderLayout()); viewsTabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); viewsTabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if we're adding a component, ignore change of active // component if (!addingView && getViewsTabbedPane().getSelectedIndex() >= 0) { setActiveComponent(getComponent(getViewsTabbedPane().getSelectedIndex())); }//from ww w.ja va 2s. co m } }); final double horizontalLocation = 0.15; final double verticalLocation = 0.75; final JSplitPane horizontalPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, projectExplorerPane, editorsPane); horizontalPane.setDividerLocation(horizontalLocation); final JSplitPane verticalPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, horizontalPane, viewsTabbedPane); verticalPane.setDividerLocation(verticalLocation); JPanel maximizedPanel = new JPanel(new BorderLayout()); maximizedPanel.add(verticalPane, BorderLayout.CENTER); JPanel control = new JPanel(new BorderLayout()); control.add(maximizedPanel, BorderLayout.CENTER); control.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { horizontalPane.setDividerLocation(horizontalLocation); verticalPane.setDividerLocation(verticalLocation); } }); this.getPageDescriptor().buildInitialLayout(this); if (viewsTabbedPane.getTabCount() > 0) { viewsTabbedPane.setSelectedIndex(0); } Logger.getRootLogger().addAppender(new AppenderSkeleton() { @Override public boolean requiresLayout() { return false; } @Override public void close() { } @SuppressWarnings("synthetic-access") @Override protected void append(LoggingEvent event) { if (event.getLevel().equals(Level.INFO)) { Object message = event.getMessage(); if (message != null) { getActiveWindow().getStatusBar().setMessage(message.toString()); } } } }); return control; }
From source file:biomine.bmvis2.pipeline.TwoPhaseExtractOperation.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { int tot = SimplificationUtils.countNormalEdges(graph); if (oldTot != 0) { int nt = (target * tot) / oldTot; if (nt != target) { target = Math.max(nt, target); }// www . j a v a 2s . co m } else { target = tot; } oldTot = tot; JPanel ret = new JPanel(); final JSlider sl = new JSlider(0, tot, Math.min(target, tot)); sl.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { if (target == sl.getValue()) return; target = sl.getValue(); v.settingsChanged(false); } }); ret.setLayout(new BoxLayout(ret, BoxLayout.Y_AXIS)); ret.add(sl); return ret; }
From source file:biomine.bmvis2.pipeline.EdgeGoodnessHider.java
public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { double maxEdge = 0; for (VisualEdge e : graph.getAllEdges()) { maxEdge = Math.max(maxEdge, e.getGoodness()); }//from w w w . ja va 2 s .c o m final int scale = 100; final JSlider limitSlider = new JSlider(); limitSlider.setMinimum(0); limitSlider.setMaximum(scale); limitSlider.setValue((int) (limit * scale)); final JTextField limitText = new JTextField(); limitText.setEditable(false); limitText.setText("" + limit); limitSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { limit = limitSlider.getValue() / (double) scale; limitText.setText("" + limit); v.settingsChanged(false); } }); JPanel ret = new JPanel(); GridBagLayout bag = new GridBagLayout(); ret.setLayout(bag); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = c.HORIZONTAL; ret.add(limitSlider, c); c.gridy++; ret.add(limitText, c); return ret; }
From source file:SwingDnDTest.java
public SwingDnDFrame() { setTitle("SwingDnDTest"); JTabbedPane tabbedPane = new JTabbedPane(); JList list = SampleComponents.list(); tabbedPane.addTab("List", list); JTable table = SampleComponents.table(); tabbedPane.addTab("Table", table); JTree tree = SampleComponents.tree(); tabbedPane.addTab("Tree", tree); JFileChooser fileChooser = new JFileChooser(); tabbedPane.addTab("File Chooser", fileChooser); JColorChooser colorChooser = new JColorChooser(); tabbedPane.addTab("Color Chooser", colorChooser); final JTextArea textArea = new JTextArea(4, 40); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here")); JTextField textField = new JTextField("Drag color here"); textField.setTransferHandler(new TransferHandler("background")); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { textArea.setText(""); }//from w ww .ja v a2 s .c om }); tree.setDragEnabled(true); table.setDragEnabled(true); list.setDragEnabled(true); fileChooser.setDragEnabled(true); colorChooser.setDragEnabled(true); textField.setDragEnabled(true); add(tabbedPane, BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); add(textField, BorderLayout.SOUTH); pack(); }
From source file:api3.transform.PlotWave.java
public void plot(double[][] signal, String name, long samplerate) { frame.setTitle(name);/*from ww w. ja v a2s . c o m*/ XYSeries[] soundWave = new XYSeries[signal.length]; for (int j = 0; j < signal.length; ++j) { soundWave[j] = new XYSeries("sygnal" + j); for (int i = 0; i < signal[0].length; ++i) { double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate; soundWave[j].add(index, signal[j][i]); } } XYSeriesCollection dataset = new XYSeriesCollection(); for (int j = 0; j < signal.length; ++j) { dataset.addSeries(soundWave[j]); } JFreeChart chart = // (samplerate ==0 )? // ChartFactory.createXYBarChart( // name, // "prbka", // false, // "warto", // new XYBarDataset(dataset,0.0625), // PlotOrientation.VERTICAL, // true,false,false) // : ChartFactory.createXYLineChart(name, "prbka", "warto", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { int value = slider.getValue(); double minimum = domainAxis.getRange().getLowerBound(); double maximum = domainAxis.getRange().getUpperBound(); double delta = (0.1f * (domainAxis.getRange().getLength())); if (value < lastValue) { // left minimum = minimum - delta; maximum = maximum - delta; } else { // right minimum = minimum + delta; maximum = maximum + delta; } DateRange range = new DateRange(minimum, maximum); domainAxis.setRange(range); lastValue = value; if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) { slider.setValue(SLIDER_DEFAULT_VALUE); } } }); plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1))); ChartPanel chartPanel = new ChartPanel(chart); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createEtchedBorder()); chartPanel.setBorder(border); chartPanel.addMouseWheelListener(addZoomWheel()); panel.add(chartPanel); JPanel dashboard = new JPanel(new BorderLayout()); dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4)); dashboard.add(slider); panel.add(dashboard, BorderLayout.SOUTH); frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:de.tbuchloh.kiskis.gui.widgets.PersistentTabPane.java
private void init(final String id) { _id = id;//from ww w. ja v a2 s. c o m this.getModel().addChangeListener(new ChangeListener() { private boolean _isActive; public void stateChanged(final ChangeEvent e) { if (_isActive && getSelectedIndex() != getLastSelectedTab()) { setLastSelectedTab(getSelectedIndex()); } _isActive = true; } }); }