List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:slash.navigation.converter.gui.profileview.ProfileView.java
public void initialize(PositionsModel positionsModel, final PositionsSelectionModel positionsSelectionModel, final UnitSystemModel unitSystemModel, final ProfileModeModel profileModeModel) { this.positionsModel = positionsModel; PatchedXYSeries series = new PatchedXYSeries("Profile"); this.profileModel = new ProfileModel(positionsModel, series, unitSystemModel.getUnitSystem(), profileModeModel.getProfileMode()); XYSeriesCollection dataset = new XYSeriesCollection(series); unitSystemModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { setUnitSystem(unitSystemModel.getUnitSystem()); }/*from w w w . j a v a 2 s. c o m*/ }); profileModeModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { setProfileMode(profileModeModel.getProfileMode()); } }); JFreeChart chart = createChart(dataset); plot = createPlot(chart); ActionManager actionManager = Application.getInstance().getContext().getActionManager(); for (ProfileMode mode : ProfileMode.values()) actionManager.register("show-" + mode.name().toLowerCase(), new ToggleProfileModeAction(profileModeModel, mode)); // since JFreeChart is not very nice to extensions - constructors calling protected methods... ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD LazyToolTipChartPanel.profileModeModel = profileModeModel; chartPanel = new LazyToolTipChartPanel(chart, false, true, true, true, true); chartPanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent e) { ChartEntity entity = e.getEntity(); if (!(entity instanceof XYItemEntity)) return; int row = ((XYItemEntity) entity).getItem(); positionsSelectionModel.setSelectedPositions(new int[] { row }, true); } public void chartMouseMoved(ChartMouseEvent e) { } }); chartPanel.setMouseWheelEnabled(true); updateAxis(); }
From source file:bestdeal.gui.Statistique.java
/** * Creates new form Statistique//from w w w . j ava2 s.c o m */ @SuppressWarnings("empty-statement") public Statistique() { initComponents(); btn_retour.setIcon((Icon) new ImageIcon("C:\\Users\\Jedidi\\Desktop\\icone\\retour.png")); panel = new ImagePanel(new ImageIcon("C:\\Users\\Jedidi\\Desktop\\111.jpg").getImage()); Panel.add(panel); lbl_log.setIcon((Icon) new ImageIcon("C:\\Users\\Jedidi\\Desktop\\Logo_.png")); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy"); lbl_date1.setText(sdf1.format(new java.util.Date())); SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss"); lbl_heure.setText(sdf2.format(new java.util.Date())); final DefaultPieDataset objDataset = new DefaultPieDataset(); VoucherDAO v2 = new VoucherDAO(); String[][] stat = v2.StatDeal(); objDataset.setValue(stat[0][0], Integer.parseInt(stat[9][0])); objDataset.setValue(stat[0][1], Integer.parseInt(stat[9][1])); objDataset.setValue(stat[0][2], Integer.parseInt(stat[9][2])); objDataset.setValue(stat[0][3], Integer.parseInt(stat[9][3])); objDataset.setValue(stat[0][4], Integer.parseInt(stat[9][4])); JFreeChart objChart = ChartFactory.createPieChart3D("Best 5 deals", objDataset, true, true, true); //String textTitle = "Best 5 deals"; TextTitle textTitle = objChart.getTitle(); textTitle.setFont(new Font("Arial", Font.BOLD, 15)); panel_deals.setLayout(new java.awt.BorderLayout()); panel_clients.setLayout(new java.awt.BorderLayout()); panel_vendeurs.setLayout(new java.awt.BorderLayout()); final ChartPanel CP = new ChartPanel(objChart); CP.setPreferredSize(new java.awt.Dimension(600, 500)); panel_deals.add(CP, BorderLayout.WEST); panel_deals.validate(); TabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (TabbedPane.getSelectedIndex() == 0) { objDataset.clear(); VoucherDAO v2 = new VoucherDAO(); String[][] stat = v2.StatDeal(); objDataset.setValue(stat[0][0], Integer.parseInt(stat[9][0])); objDataset.setValue(stat[0][1], Integer.parseInt(stat[9][1])); objDataset.setValue(stat[0][2], Integer.parseInt(stat[9][2])); objDataset.setValue(stat[0][3], Integer.parseInt(stat[9][3])); objDataset.setValue(stat[0][4], Integer.parseInt(stat[9][4])); panel_deals.add(CP, BorderLayout.WEST); panel_deals.validate(); } else if (TabbedPane.getSelectedIndex() == 1) { objDataset.clear(); VoucherDAO v2 = new VoucherDAO(); String[][] stat = v2.StatVendeur(); objDataset.setValue(stat[1][0], Integer.parseInt(stat[7][0])); objDataset.setValue(stat[1][1], Integer.parseInt(stat[7][1])); objDataset.setValue(stat[1][2], Integer.parseInt(stat[7][2])); objDataset.setValue(stat[1][3], Integer.parseInt(stat[7][3])); objDataset.setValue(stat[1][4], Integer.parseInt(stat[7][4])); panel_vendeurs.add(CP, BorderLayout.WEST); panel_vendeurs.validate(); } else if (TabbedPane.getSelectedIndex() == 2) { objDataset.clear(); VoucherDAO v2 = new VoucherDAO(); String[][] stat = v2.StatClient(); objDataset.setValue(stat[1][0], Integer.parseInt(stat[4][0])); objDataset.setValue(stat[1][1], Integer.parseInt(stat[4][1])); objDataset.setValue(stat[1][2], Integer.parseInt(stat[4][2])); objDataset.setValue(stat[1][3], Integer.parseInt(stat[4][3])); objDataset.setValue(stat[1][4], Integer.parseInt(stat[4][4])); panel_clients.add(CP, BorderLayout.WEST); panel_clients.validate(); } else if (TabbedPane.getSelectedIndex() == 3) { } } }); }
From source file:gtu._work.etc.EnglishAdd.java
private void initGUI() { try {//from ww w . j ava 2 s . co m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setPreferredSize(new java.awt.Dimension(400, 211)); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { if (jTabbedPane1.getSelectedIndex() == 2) { // XXX } } }); { jPanel1 = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("add", null, jPanel1, null); jPanel1.setPreferredSize(new java.awt.Dimension(387, 233)); { showwordText = new JTextField(); jPanel1.add(showwordText); showwordText.setPreferredSize(new java.awt.Dimension(271, 23)); showwordText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) { scanWord(); } } }); showwordText.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { scanWord(); } }); } { netChkBox = new JCheckBox(); jPanel1.add(netChkBox); netChkBox.setSelected(true); } { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2); jScrollPane2.setPreferredSize(new java.awt.Dimension(364, 80)); { showChineseArea = new JTextArea(); jScrollPane2.setViewportView(showChineseArea); showChineseArea.setPreferredSize(new java.awt.Dimension(364, 80)); } } { setFileBtn = new JButton(); jPanel1.add(setFileBtn); setFileBtn.setText("set file"); setFileBtn.setPreferredSize(new java.awt.Dimension(261, 30)); setFileBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("?!"); return; } currentFile = file; StringBuffer sb = new StringBuffer(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(currentFile), "BIG5")); for (String line = null; (line = reader.readLine()) != null;) { sb.append(line + "\r\n"); } reader.close(); } catch (IOException e) { e.printStackTrace(); } wordTextArea.setText(sb.toString()); } }); } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("word", null, jPanel3, null); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(387, 224)); { wordTextArea = new JTextArea(); jScrollPane1.setViewportView(wordTextArea); } } } } setDefaultSave(); pack(); this.setSize(400, 211); } catch (Exception e) { // add your error handling code here e.printStackTrace(); } }
From source file:com.anrisoftware.prefdialog.fields.spinner.SpinnerField.java
/** * @see SpinnerFieldFactory#create(Object, String) *//*w w w.j av a 2 s .co m*/ @Inject SpinnerField(SpinnerFieldLogger logger, @Assisted Object parentObject, @Assisted String fieldName) { super(new JSpinner(), parentObject, fieldName); this.log = logger; this.customModelSet = false; this.changeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { try { setValue(getComponent().getValue()); } catch (PropertyVetoException e1) { } } }; }
From source file:BlendCompositeDemo.java
public BlendCompositeDemo() { super("Blend Composites"); compositeTestPanel = new CompositeTestPanel(); compositeTestPanel.setComposite(BlendComposite.Average); add(compositeTestPanel);/* ww w .j a va 2 s .c o m*/ combo = new JComboBox(BlendComposite.BlendingMode.values()); combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { compositeTestPanel.setComposite(BlendComposite.getInstance( BlendComposite.BlendingMode.valueOf(combo.getSelectedItem().toString()), slider.getValue() / 100.0f)); } }); slider = new JSlider(0, 100, 100); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { BlendComposite blend = (BlendComposite) compositeTestPanel.getComposite(); blend = blend.derive(slider.getValue() / 100.0f); compositeTestPanel.setComposite(blend); } }); JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT)); controls.add(combo); controls.add(new JLabel("0%")); controls.add(slider); controls.add(new JLabel("100%")); add(controls, BorderLayout.SOUTH); pack(); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:org.csml.tommo.sugar.modules.heatmap.MixedHeatmapDialog.java
private JSlider createMixParameterSlider() { JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, (int) (mixOperation.getParameter() * 100.0)); slider.setMajorTickSpacing(10);//from ww w .j a v a2 s. co m slider.setSnapToTicks(true); slider.setPaintTicks(true); // slider.setPaintLabels(true); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSlider source = (JSlider) event.getSource(); if (!source.getValueIsAdjusting()) { double param = (double) source.getValue() / (double) 100.0; updateMixParameter(param); } } }); return slider; }
From source file:com.rapidminer.gui.plotter.DistributionPlotter.java
public DistributionPlotter() { kernelSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (!kernelSlider.getValueIsAdjusting()) { repaint();/*from w w w . j av a 2 s. co m*/ } } }); }
From source file:com.anrisoftware.prefdialog.fields.fieldbutton.AbstractFieldButtonField.java
private Object readResolve() { this.valueAction = new ActionListener() { @Override//from w w w . jav a2 s. c o m public void actionPerformed(ActionEvent e) { try { setValue(getComponent().isSelected()); } catch (PropertyVetoException e1) { } } }; this.changeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { try { setValue(getComponent().isSelected()); } catch (PropertyVetoException e1) { } } }; return this; }
From source file:REDemo.java
/** Construct the REDemo object including its GUI */ public REDemo() { super();//from ww w. ja v a2 s . c o m JPanel top = new JPanel(); top.add(new JLabel("Pattern:", JLabel.RIGHT)); patternTF = new JTextField(20); patternTF.getDocument().addDocumentListener(new PatternListener()); top.add(patternTF); top.add(new JLabel("Syntax OK?")); compiledOK = new JCheckBox(); top.add(compiledOK); ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent ce) { tryMatch(); } }; JPanel switchPane = new JPanel(); ButtonGroup bg = new ButtonGroup(); match = new JRadioButton("Match"); match.setSelected(true); match.addChangeListener(cl); bg.add(match); switchPane.add(match); find = new JRadioButton("Find"); find.addChangeListener(cl); bg.add(find); switchPane.add(find); findAll = new JRadioButton("Find All"); findAll.addChangeListener(cl); bg.add(findAll); switchPane.add(findAll); JPanel strPane = new JPanel(); strPane.add(new JLabel("String:", JLabel.RIGHT)); stringTF = new JTextField(20); stringTF.getDocument().addDocumentListener(new StringListener()); strPane.add(stringTF); strPane.add(new JLabel("Matches:")); matchesTF = new JTextField(3); strPane.add(matchesTF); setLayout(new GridLayout(0, 1, 5, 5)); add(top); add(strPane); add(switchPane); }
From source file:projects.tgas.exec.HrDiagram.java
/** * Main constructor.// www . j a v a2 s . c om */ public HrDiagram() { tgasStars = TgasUtils.loadTgasCatalogue(); method = METHOD.NAIVE; fMax = 1.0; final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(2, 2)); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(hrDiagPanel, BorderLayout.CENTER); add(controls, BorderLayout.SOUTH); }