List of usage examples for java.awt.event ItemEvent getStateChange
public int getStateChange()
From source file:ComponentEventDemo.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { label.setVisible(true);//from w ww . j a v a2 s . c o m //Need to revalidate and repaint, or else the label //will probably be drawn in the wrong place. label.revalidate(); label.repaint(); } else { label.setVisible(false); } }
From source file:Composite.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() != ItemEvent.SELECTED) { return;/* w ww. ja v a 2s. com*/ } Object choice = e.getSource(); if (choice == alphas) { alpha = (String) alphas.getSelectedItem(); } else { rule = rules.getSelectedIndex(); } comp.changeRule(alpha, rule); }
From source file:misc.AccessibleScrollDemo.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // Turn it to metric. rowView.setIsMetric(true);/*w ww .j ava 2s . c om*/ columnView.setIsMetric(true); } else { // Turn it to inches. rowView.setIsMetric(false); columnView.setIsMetric(false); } picture.setMaxUnitIncrement(rowView.getIncrement()); }
From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.support.FileSelectionComponent.java
private void createComponent(Predicate projectFilter) { projectsCombobox = new JComboBox(projectList(projectFilter)); new ComboBoxAutoCompletion(projectsCombobox); model = new DefaultListModel(); list = new JList(model); list.setPreferredSize(new Dimension(150, 150)); projectsCombobox.addItemListener(new ItemListener() { @Override/*from ww w. java 2s . c om*/ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateList(e.getItem()); } } }); setLayout(new BorderLayout()); add(projectsCombobox, BorderLayout.NORTH); add(new JScrollPane(list), BorderLayout.CENTER); }
From source file:GlassPaneDemo.java
public void itemStateChanged(ItemEvent e) { setVisible(e.getStateChange() == ItemEvent.SELECTED); }
From source file:org.cagrid.installer.steps.PresentLicenseStep.java
public void init(WizardModel m) { this.model = (CaGridInstallerModel) m; setLayout(new BorderLayout()); setSize(new Dimension(475, 161)); JPanel licensePanel = new JPanel(); licensePanel.setBackground(Color.WHITE); JTextPane textPane = new JTextPane(); licensePanel.add(textPane);//from w w w . j ava 2 s . c o m JScrollPane scrollPane = new JScrollPane(licensePanel); scrollPane.setPreferredSize(new Dimension(475, 150)); add(scrollPane, BorderLayout.CENTER); try { StringBuilder sb = new StringBuilder(); BufferedReader r = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/cagrid_license.txt"))); String line = null; while ((line = r.readLine()) != null) { sb.append(line).append("\n"); } textPane.setText(sb.toString()); textPane.setFont(textPane.getFont().deriveFont((float) 10)); } catch (Exception ex) { String msg = "Error loading license: " + ex.getMessage(); logger.error(msg, ex); JOptionPane.showMessageDialog(null, msg, this.model.getMessage("error"), JOptionPane.ERROR_MESSAGE); } JPanel controlPanel = new JPanel(); controlPanel.setLayout(new GridBagLayout()); add(controlPanel, BorderLayout.SOUTH); JLabel label = new JLabel(this.model.getMessage("accept.license")); controlPanel.add(label); JCheckBox checkBox = new JCheckBox(); checkBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { PresentLicenseStep.this.setComplete(evt.getStateChange() == ItemEvent.SELECTED); } }); controlPanel.add(checkBox); }
From source file:org.pentaho.ui.xul.swing.tags.SwingRadio.java
public SwingRadio(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) { super("radio"); radioButton = new JRadioButton(); setManagedObject(radioButton);/*from ww w. java 2 s . c o m*/ // wrong type of event to listen to.. this one fires even on mouse over. use itemlistener // radioButton.addChangeListener(new ChangeListener(){ // public void stateChanged(ChangeEvent evt){ // logger.debug("firing selected property change: isSelected="+SwingRadio.this.isSelected()); // SwingRadio.this.changeSupport.firePropertyChange("selected", null, SwingRadio.this.isSelected()); // } // }); radioButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = (e.getStateChange() == ItemEvent.SELECTED); logger.debug("firing selected property change: isSelected=" + selected); SwingRadio.this.changeSupport.firePropertyChange("selected", null, selected); } }); }
From source file:assign3.client.WaypointClient.java
public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Object comp = event.getSource(); debug("Selection event generated by " + ((comp == frWps) ? "from " : "to ") + "combobox. " + "Selected waypoint is: " + (String) event.getItem()); String To = "to waypoint"; String From = "from waypoint"; String currentSelection;//from w ww . j av a 2 s . com if (comp == frWps) { currentSelection = frWps.getSelectedItem().toString(); } else { currentSelection = toWps.getSelectedItem().toString(); } if ((currentSelection == "from waypoint") || (currentSelection == "to waypoint")) { latIn.setText("null"); lonIn.setText("null"); eleIn.setText("null"); nameIn.setText("null"); addrIn.setText("null"); } else { try { Waypoint currentWaypoint = server.get(currentSelection); //System.out.println("Description Changed: "+server.get(currentSelection)); latIn.setText(String.valueOf(currentWaypoint.getLat())); lonIn.setText(String.valueOf(currentWaypoint.getLon())); eleIn.setText(String.valueOf(currentWaypoint.getEle())); nameIn.setText(currentWaypoint.getName()); addrIn.setText(currentWaypoint.getAddr()); } catch (RemoteException e) { System.out.println("Error retrieving name from server."); } } } }
From source file:org.csml.tommo.sugar.modules.heatmap.MixedHeatmapDialog.java
public MixOperationComboBox createMixOperationComboBox() { MixOperationComboBox comboBox = new MixOperationComboBox(); comboBox.addItemListener(new ItemListener() { @Override/*ww w .j a v a 2 s.c o m*/ public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { MixOperationComboBox box = (MixOperationComboBox) e.getSource(); double param = mixOperation.getParameter(); IMixOperation newMixOperation = box.getSelectedItem().getMixer(); newMixOperation.setParameter(param); updateMixOperation(newMixOperation); } } }); return comboBox; }
From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java
public ConsolePanel(PluginDelegate service) { super(service); setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]")); JComboBox comboBox = new JComboBox(); comboBox.setToolTipText("Log Level"); comboBox.setMaximumRowCount(6);//from w w w .j a va 2 s. c o m comboBox.setModel( new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" })); comboBox.setSelectedIndex(5); add(comboBox, "cell 1 0,growx"); JButton btnC = new JButton(""); btnC.setToolTipText("Clear Buffer"); btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png"))); btnC.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { logPangrams(); } }); add(btnC, "cell 2 0,wmax 24,hmax 26"); tglbtnV = new JToggleButton(""); tglbtnV.setToolTipText("Auto Scroll"); tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png"))); tglbtnV.setSelected(true); tglbtnV.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { _table.setAutoScroll(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { _table.setAutoScroll(false); } } }); add(tglbtnV, "cell 3 0,wmax 24,hmax 26"); scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { // TODO figure out what to do with this event? } }); add(scrollPane, "cell 0 1 4 1,grow"); _table = new JLogTable("Time", "Source", "Message"); _table.getColumnModel().getColumn(0).setMinWidth(50); _table.getColumnModel().getColumn(0).setPreferredWidth(50); _table.getColumnModel().getColumn(0).setMaxWidth(100); _table.getColumnModel().getColumn(1).setMinWidth(50); _table.getColumnModel().getColumn(1).setPreferredWidth(50); _table.getColumnModel().getColumn(1).setMaxWidth(100); _table.getColumnModel().getColumn(2).setMinWidth(50); _table.getColumnModel().getColumn(2).setWidth(255); _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollPane.setViewportView(_table); _appender = new JLogTableAppender(); _appender.setThreshold(Level.ALL); Logger.getRootLogger().addAppender(_appender); }