List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:com.kstenschke.copypastestack.ToolWindow.java
private void initMainToolbar() { this.form.buttonRefresh.addActionListener(new ActionListener() { @Override// w w w . j a v a 2 s. c o m public void actionPerformed(ActionEvent e) { refreshClipboardList(); } }); this.form.buttonRefresh.addMouseListener(new MouseListenerBase(StaticTexts.INFO_REFRESH)); this.form.buttonSortAlphabetical.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sortClipboardListAlphabetical(); } }); this.form.buttonSortAlphabetical.addMouseListener(new MouseListenerBase(StaticTexts.INFO_SORT)); this.form.checkboxKeepSorted.setSelected(Preferences.getIsActiveKeepSorting()); this.form.checkboxKeepSorted .addMouseListener(new MouseListenerBase(StaticTexts.INFO_KEEP_SORTED_ALPHABETICAL)); this.form.checkboxKeepSorted.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { boolean isActive = form.checkboxKeepSorted.isSelected(); if (isActive) { sortClipboardListAlphabetical(); } else { refreshClipboardList(); } Preferences.saveIsActiveKeepSorting(isActive); } }); this.form.buttonDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeItemsFromStack(e); } }); this.form.buttonDelete.addMouseListener(new MouseListenerBase(StaticTexts.INFO_DELETE)); this.form.buttonPaste.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteItems(); } }); this.form.buttonPaste.addMouseListener(new MouseListenerBase(StaticTexts.INFO_PASTE)); this.form.buttonCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copySelectedItems(); } }); this.form.buttonCopy.addMouseListener(new MouseListenerBase(StaticTexts.INFO_RECOPY)); this.initTagOptions(); this.initAdditionalOptions(); }
From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java
/** * Creates new form DSWorkbenchTroopsFrame *///ww w. j av a 2 s . co m DSWorkbenchTroopsFrame() { initComponents(); centerPanel = new GenericTestPanel(true); jTroopsPanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jXTroopsPanel); buildMenu(); capabilityInfoPanel1.addActionListener(this); jTroopsTabPane.getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { TroopTableTab activeTab = getActiveTab(); if (activeTab != null) { activeTab.updateSet(); } } }); DataHolder.getSingleton().addDataHolderListener(DSWorkbenchTroopsFrame.this); jXGroupsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateFilter(); } }); jTroopAddTribe.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateTroopAddVillageList(); } } }); jTroopsAddDialog.pack(); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.troops_view", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> setGlassPane(jxSearchPane); pack(); }
From source file:com.moteiv.trawler.Trawler.java
protected Box getControls() { java.util.Dictionary labels;//from ww w .j av a 2 s . c om if (controls == null) { controls = Box.createVerticalBox(); JPanel runtimeControls = new JPanel(new GridLayout(0, 1)); runtimeControls.setBorder(BorderFactory.createTitledBorder("Runtime Controls")); vLog = new JCheckBox("Log packets", false); vLog.addActionListener(this); runtimeControls.add(vLog); runtimeControls.add(new JLabel("Edge persistence (sec)", JLabel.LEFT)); eDispose = new JSlider(0, 300, 10); eDispose.setMajorTickSpacing(100); eDispose.setMinorTickSpacing(10); eDispose.setPaintTicks(true); eDispose.setPaintTrack(true); // labels = eDispose.getLabelTable(); eDispose.setPaintLabels(true); eDispose.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { LinkData.setEdgeDelay((1 + eDispose.getValue()) * 1000); savePrefs(); } }); runtimeControls.add(eDispose); runtimeControls.add(new JLabel("Vertex persistence (sec)", JLabel.LEFT)); vDispose = new JSlider(0, 300, 30); vDispose.setMajorTickSpacing(100); vDispose.setMinorTickSpacing(10); vDispose.setPaintTicks(true); vDispose.setPaintTrack(true); vDispose.setPaintLabels(true); vDispose.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { NodeData.setNodeDelay((1 + vDispose.getValue()) * 1000); savePrefs(); } }); runtimeControls.add(vDispose); graphReset = new JButton("Reset Nodes"); graphReset.addActionListener(this); runtimeControls.add(graphReset); controls.add(runtimeControls); JPanel vertexControl = new JPanel(new GridLayout(0, 1)); vertexControl.setBorder(BorderFactory.createTitledBorder("Node display")); vLabels = new JCheckBox("Display vertex details", true); vLabels.addActionListener(this); vertexControl.add(vLabels); vBlink = new JCheckBox("Blink on incoming packets"); vBlink.addActionListener(this); vertexControl.add(vBlink); vSave = new JCheckBox("Save node locations", true); vSave.addActionListener(this); vertexControl.add(vSave); controls.add(vertexControl); JPanel edgeControl = new JPanel(new GridLayout(0, 1)); edgeControl.setBorder(BorderFactory.createTitledBorder("Link diplay")); eLabels = new JCheckBox("Display link quality", true); eLabels.addActionListener(this); edgeControl.add(eLabels); eFilter = new JCheckBox("Show alternate parents", true); eFilter.addActionListener(this); edgeControl.add(eFilter); controls.add(edgeControl); } return controls; }
From source file:mulavito.gui.components.LayerViewer.java
public LayerViewer(Layout<V, E> layout, ILayer<V, E> g) { super(layout); this.g = g;/* www .j a va2 s.com*/ if (layout.getGraph() != g) layout.setGraph(g); // Cache the graph size. updateGraphBoundsCache(); if (getGraphLayout() instanceof ChangeEventSupport) ((ChangeEventSupport) getGraphLayout()).addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateGraphBoundsCache(); } }); }
From source file:io.github.jeremgamer.editor.panels.MusicFrame.java
public MusicFrame(JFrame frame, final GeneralSave gs) { ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {// w ww. ja v a 2 s . co m icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Musique"); this.setSize(new Dimension(300, 225)); this.addWindowListener(new WindowListener() { @Override public void windowActivated(WindowEvent event) { } @Override public void windowClosed(WindowEvent event) { } @Override public void windowClosing(WindowEvent event) { try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } @Override public void windowDeactivated(WindowEvent event) { } @Override public void windowDeiconified(WindowEvent event) { } @Override public void windowIconified(WindowEvent event) { } @Override public void windowOpened(WindowEvent event) { } }); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); this.setModal(true); this.setLocationRelativeTo(frame); JPanel properties = new JPanel(); properties.setBorder(BorderFactory.createTitledBorder("Lecture")); ButtonGroup bg = new ButtonGroup(); bg.add(one); bg.add(loop); one.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 0); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(0); } } } }); loop.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JRadioButton rb = (JRadioButton) event.getSource(); if (rb.isSelected()) { gs.set("music.reading", 1); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } if (clip != null) { if (clip.isRunning()) clip.loop(Clip.LOOP_CONTINUOUSLY); } } } }); properties.add(one); properties.add(loop); if (gs.getInt("music.reading") == 0) { one.setSelected(true); } else { loop.setSelected(true); } volume.setMaximum(100); volume.setMinimum(0); volume.setValue(30); volume.setPaintTicks(true); volume.setPaintLabels(true); volume.setMinorTickSpacing(10); volume.setMajorTickSpacing(20); volume.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { JSlider slider = (JSlider) event.getSource(); double value = slider.getValue(); gain = value / 100; dB = (float) (Math.log(gain) / Math.log(10.0) * 20.0); if (clip != null) gainControl.setValue(dB); gs.set("music.volume", (int) value); } }); volume.setValue(gs.getInt("music.volume")); properties.add(volume); properties.setPreferredSize(new Dimension(300, 125)); content.add(properties); JPanel browsePanel = new JPanel(); browsePanel.setBorder(BorderFactory.createTitledBorder("")); JButton browse = new JButton("Parcourir..."); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(false); browse.setText(""); try { browse.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } } browse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton button = (JButton) event.getSource(); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { if (clip != null) { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } name.setText(""); preview.setEnabled(false); button.setText("Parcourir..."); button.setIcon(null); new File("projects/" + Editor.getProjectName() + "/music.wav").delete(); gs.set("music.name", ""); } else { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Audio (WAV)", "wav"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyMusic(new File(path)); button.setText(""); try { button.setIcon( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } gs.set("music.name", new File(path).getName()); try { gs.save(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e) { e.printStackTrace(); } name.setText(new File(path).getName()); preview.setEnabled(true); } } } }); if (new File("projects/" + Editor.getProjectName() + "/music.wav").exists()) { preview.setEnabled(true); } else { preview.setEnabled(false); } preview.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JToggleButton tb = (JToggleButton) event.getSource(); if (tb.isSelected()) { try { audioStream = AudioSystem.getAudioInputStream( new File("projects/" + Editor.getProjectName() + "/music.wav")); format = audioStream.getFormat(); info = new DataLine.Info(Clip.class, format); clip = (Clip) AudioSystem.getLine(info); clip.open(audioStream); clip.start(); gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN); gainControl.setValue(dB); if (loop.isSelected()) { clip.loop(Clip.LOOP_CONTINUOUSLY); } else { clip.loop(0); } clip.addLineListener(new LineListener() { @Override public void update(LineEvent event) { Clip clip = (Clip) event.getSource(); if (!clip.isRunning()) { preview.setSelected(false); clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); } catch (Exception exc) { exc.printStackTrace(); } } else { clip.stop(); clip.close(); try { audioStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BorderLayout()); buttons.add(browse, BorderLayout.WEST); buttons.add(preview, BorderLayout.EAST); browsePanel.setLayout(new BorderLayout()); browsePanel.add(buttons, BorderLayout.NORTH); browsePanel.add(name, BorderLayout.SOUTH); name.setPreferredSize(new Dimension(280, 25)); name.setText(gs.getString("music.name")); content.add(browsePanel); this.setContentPane(content); this.setVisible(true); }
From source file:edu.ku.brc.specify.datamodel.busrules.InstitutionBusRules.java
@Override public void afterFillForm(final Object dataObj) { super.afterFillForm(dataObj); if (checkbox == null && dataObj != null) { Component comp = formViewObj.getControlById("curMgrRelVer"); if (comp instanceof ValComboBox) { relCombobox = (ValComboBox) comp; }//from w w w . jav a 2 s . c o m comp = formViewObj.getControlById("isRelMgrGlb"); if (relCombobox != null && comp instanceof ValCheckBox) { checkbox = (ValCheckBox) comp; checkbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { relCombobox.setEnabled(checkbox.isSelected()); ((JLabel) formViewObj.getLabelById("curMgrRelVerLbl")).setEnabled(checkbox.isSelected()); } }); final Institution inst = (Institution) viewable.getDataObj(); if (inst != null) { Vector<String> releases = new Vector<String>(); String curRelease = AppPreferences.getGlobalPrefs().get(RELEASES, null); if (curRelease == null) { curRelease = UIHelper.getInstall4JInstallString(); AppPreferences.getGlobalPrefs().put(RELEASES, curRelease); } releases.add(curRelease); String managedRelease = inst.getCurrentManagedRelVersion(); if (managedRelease == null) { managedRelease = curRelease; inst.setCurrentManagedRelVersion(managedRelease); } boolean releaseNumMismatch = !managedRelease.equals(curRelease); if (releaseNumMismatch) { releases.insertElementAt(managedRelease, 0); } relCombobox.getComboBox().setModel(new DefaultComboBoxModel(releases)); relCombobox.getComboBox().setSelectedIndex(releaseNumMismatch ? 1 : 0); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { UIValidator.setIgnoreAllValidation(this, true); try { checkbox.setSelected(!inst.getIsReleaseManagedGlobally()); // make sure the ChangeListener gets activated checkbox.setSelected(inst.getIsReleaseManagedGlobally()); } catch (Exception ex) { } finally { UIValidator.setIgnoreAllValidation(this, false); } } }); } } } }
From source file:com.projity.pm.graphic.chart.TimeChartPanel.java
public void configureScrollPaneHeaders(JScrollPane scrollPane, JComponent rowHeader) { viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) return;/*from ww w . j av a 2 s .co m*/ JViewport vp = new JViewport(); vp.setView(rowHeader); vp.setPreferredSize(rowHeader.getPreferredSize()); scrollPane.setRowHeader(vp); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, new ChartCorner(this)); Border border = scrollPane.getBorder(); if (border == null || border instanceof UIResource) { scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } // left scale synchro viewport.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { updateTimeScaleComponentSize(); } }); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return//from w w w . j a va 2 s.c om */ private Component createContentPanel() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); scriptEditorTA = new RSyntaxTextArea(); setSyntaxStyle(); RTextScrollPane sp = new RTextScrollPane(scriptEditorTA); pane.setTopComponent(sp); JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel panel = new JPanel(new BorderLayout()); output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT); output.setEditable(false); output.setAutoscrolls(true); output.setScrollContent(true); output.setWrapStyleWord(true); scrollPane.setViewportView(output); JToolBar toolBar = new JToolBar(); JButton clearBT = new JButton("Clear"); clearBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { output.setText(INITIAL_OUTPUT_CONTENT); } }); final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content"); scrollCB.setSelected(true); scrollCB.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { output.setScrollContent(scrollCB.isSelected()); } }); toolBar.add(clearBT); toolBar.add(scrollCB); panel.add(toolBar, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); pane.setBottomComponent(panel); pane.setDividerLocation(300); return pane; }
From source file:com.rapidminer.gui.viewer.MatrixGraphCreator.java
public JComponent getOptionComponent(final GraphViewer viewer, int index) { if (index == 0) { return new JLabel("Number of Edges:"); } else if (index == 1) { this.distanceSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (!distanceSlider.getValueIsAdjusting()) { addEdges();/*from w w w. j av a2 s . c o m*/ viewer.updateLayout(); } } }); return distanceSlider; } else { return null; } }
From source file:MessagePopup.java
public static JSlider getSlider(final JOptionPane optionPane) { JSlider slider = new JSlider(); slider.setMajorTickSpacing(10);// w ww. j a v a 2 s .c om slider.setPaintTicks(true); slider.setPaintLabels(true); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JSlider theSlider = (JSlider) changeEvent.getSource(); if (!theSlider.getValueIsAdjusting()) { optionPane.setInputValue(new Integer(theSlider.getValue())); } } }; slider.addChangeListener(changeListener); return slider; }