List of usage examples for java.awt.event ItemEvent getStateChange
public int getStateChange()
From source file:org.apache.jmeter.testbeans.gui.ComboStringEditor.java
/** * {@inheritDoc}// ww w. j av a2 s. c om */ @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (EDIT.equals(e.getItem())) { startingEdit = true; startEditing(); startingEdit = false; } else { if (!startingEdit && combo.getSelectedIndex() >= 0) { combo.setEditable(false); } firePropertyChange(); } } }
From source file:op.controlling.DlgQMSPlan.java
private void cmbNotifyItemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!notifyList.contains(e.getItem())) { notifyList.add((Users) e.getItem()); lstNotify.setModel(SYSTools.list2dlm(notifyList)); }/* w w w. j a v a 2 s. c om*/ } }
From source file:org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui.java
protected JPanel createEmbeddedRsrcPanel() { // retrieve Embedded resources retrieveEmbeddedResources = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$ // add a listener to activate or not concurrent dwn. retrieveEmbeddedResources.addItemListener(new ItemListener() { @Override/*w w w. ja v a 2 s .c o m*/ public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); } else { enableConcurrentDwn(false); } } }); // Download concurrent resources concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$ concurrentDwn.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (retrieveEmbeddedResources.isSelected() && e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); } else { concurrentPool.setEnabled(false); } } }); concurrentPool = new JTextField(2); // 2 columns size concurrentPool.setMinimumSize(new Dimension(10, (int) concurrentPool.getPreferredSize().getHeight())); concurrentPool.setMaximumSize(new Dimension(30, (int) concurrentPool.getPreferredSize().getHeight())); final JPanel embeddedRsrcPanel = new HorizontalPanel(); embeddedRsrcPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("web_testing_retrieve_title"))); // $NON-NLS-1$ embeddedRsrcPanel.add(retrieveEmbeddedResources); embeddedRsrcPanel.add(concurrentDwn); embeddedRsrcPanel.add(concurrentPool); // Embedded URL match regex embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"), 20); // $NON-NLS-1$ embeddedRsrcPanel.add(embeddedRE); return embeddedRsrcPanel; }
From source file:org.pentaho.ui.xul.swing.tags.SwingMenuList.java
public SwingMenuList(Element self, XulComponent parent, XulDomContainer domContainer, String tagName) { super("menulist"); this.xulDomContainer = domContainer; combobox = new JComboBox(new DefaultComboBoxModel()); setManagedObject(combobox);// www .j a v a 2 s . c om combobox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED && !inLayoutProcess && initialized) { fireSelectedEvents(); } } }); }
From source file:org.apache.jmeter.protocol.system.gui.SystemSamplerGui.java
@Override public void itemStateChanged(ItemEvent e) { if (e.getSource() == checkReturnCode) { desiredReturnCode.setEnabled(e.getStateChange() == ItemEvent.SELECTED); }//from w w w.j a v a 2s .co m }
From source file:org.openmicroscopy.shoola.agents.treeviewer.util.SaveResultsDialog.java
/** * Builds and lays out the elements indicating what to save. * * @return See above.//from w ww . jav a 2 s . co m */ private JPanel buildContents() { JPanel buttons = new JPanel(); buttons.add(UIUtilities.setTextFont("Save results for")); buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS)); ButtonGroup group = new ButtonGroup(); JRadioButton b = new JRadioButton("Image from current window"); b.setSelected(activeWindow); buttons.add(b); group.add(b); b.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { activeWindow = (e.getStateChange() == ItemEvent.SELECTED); } }); b = new JRadioButton("Images from all image windows"); b.setSelected(activeWindow); buttons.add(b); group.add(b); buttons.add(Box.createRigidArea(UIUtilities.H_SPACER_SIZE)); buttons.add(UIUtilities.setTextFont("Save")); buttons.add(roi); buttons.add(table); JPanel row = new JPanel(); row.setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel l = new JLabel(); l.setText("Measurements File Name: "); row.add(l); row.add(nameField); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(UIUtilities.buildComponentPanel(buttons)); p.add(row); return p; }
From source file:model.utilities.ExchangeNetwork.java
/** * Create the network: both the structure and the visualization *//* ww w .jav a 2 s . c o m*/ public ExchangeNetwork(GoodType type) { assert MacroII.hasGUI(); //don't bother with any of this if there is no inventory //create the graph! inventoryGraph = new DirectedSparseGraph<>(); //record your good type this.type = type; //create the layout used for vertices Layout<EconomicAgent, InventoryEdge> layout = new SpringLayout<EconomicAgent, InventoryEdge>( inventoryGraph); //new DAGLayout<EconomicAgent, InventoryEdge>(inventoryGraph); layout.setSize(new Dimension(600, 600)); //set size //create the viewer vv = new VisualizationViewer<>(layout); //tell it how to color the vertices vv.getRenderContext().setVertexFillPaintTransformer(vertexPainter); //tell it to print the name of the vertices vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<EconomicAgent>()); //call to string to label edges vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<InventoryEdge>()); //edges will have name //have the thickness of lines grow vv.getRenderContext().setEdgeStrokeTransformer(InventoryEdge.edgeStrokeTransformer); //now set up the visualization so that clicking on an agent gives you info about him //set up the mouse to select ModalGraphMouse mouse = new DefaultModalGraphMouse<>(); mouse.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(mouse); //make selection communicate to Mason through inspectors vv.getPickedVertexState().addItemListener(new ItemListener() { @Override //when you have a selection, this logEvent is fired public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) //if e is selected { EconomicAgent agent = (EconomicAgent) e.getItem(); //cast it to agent Inspector inspector = agent.getInspector(MacroII.getGUI()); //notice how you get back the outer instance //now for the moronic, let's talk to MASON in java 1.3 language because computer science people are too smart //to use generics or arraylists Bag inspectors = new Bag(1); inspectors.add(inspector); Bag names = new Bag(1); names.add(agent.toString()); MacroII.getGUI().controller.setInspectors(inspectors, names); } } }); }
From source file:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes *//*w w w.ja v a 2 s. c om*/ public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }
From source file:org.kontalk.view.ThreadDetails.java
ThreadDetails(final Component focusGainer, KonThread thread) { mThread = thread;/* w w w . j ava 2s. c om*/ GroupPanel groupPanel = new GroupPanel(View.GAP_BIG, false); groupPanel.setMargin(View.MARGIN_BIG); groupPanel.add(new WebLabel(Tr.tr("Edit Chat")).setBoldFont()); groupPanel.add(new WebSeparator(true, true)); // editable fields groupPanel.add(new WebLabel(Tr.tr("Subject:"))); String subj = mThread.getSubject(); mSubjectField = new WebTextField(subj, 22); mSubjectField.setInputPrompt(subj); mSubjectField.setHideInputPromptOnFocus(false); groupPanel.add(mSubjectField); groupPanel.add(new WebSeparator(true, true)); final WebSlider colorSlider = new WebSlider(WebSlider.HORIZONTAL); groupPanel.add(new WebLabel(Tr.tr("Custom Background"))); mColorOpt = new WebRadioButton(Tr.tr("Color:") + " "); Optional<Color> optBGColor = mThread.getViewSettings().getBGColor(); mColorOpt.setSelected(optBGColor.isPresent()); mColorOpt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { colorSlider.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mColor = new WebButton(); mColor.setMinimumHeight(25); Color oldColor = optBGColor.orElse(DEFAULT_BG); mColor.setBottomBgColor(oldColor); groupPanel.add(new GroupPanel(GroupingType.fillLast, mColorOpt, mColor)); colorSlider.setMinimum(0); colorSlider.setMaximum(100); colorSlider.setPaintTicks(false); colorSlider.setPaintLabels(false); colorSlider.setEnabled(optBGColor.isPresent()); final GradientData gradientData = GradientData.getDefaultValue(); // TODO set location for color gradientData.getColor(0); colorSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { float v = colorSlider.getValue() / (float) 100; Color c = gradientData.getColorForLocation(v); mColor.setBottomBgColor(c); mColor.repaint(); } }); groupPanel.add(colorSlider); mImgOpt = new WebRadioButton(Tr.tr("Image:") + " "); String imgPath = mThread.getViewSettings().getImagePath(); mImgOpt.setSelected(!imgPath.isEmpty()); mImgOpt.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { mImgChooser.setEnabled(e.getStateChange() == ItemEvent.SELECTED); mImgChooser.getChooseButton().setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); mImgChooser = Utils.createImageChooser(!imgPath.isEmpty(), imgPath); groupPanel.add(new GroupPanel(GroupingType.fillLast, mImgOpt, mImgChooser)); UnselectableButtonGroup.group(mColorOpt, mImgOpt); groupPanel.add(new WebSeparator()); // groupPanel.add(new WebLabel(Tr.tr("Participants:"))); // mParticipantsList = new WebCheckBoxList(); // mParticipantsList.setVisibleRowCount(10); // for (User oneUser : UserList.getInstance().getAll()) { // boolean selected = mThread.getUser().contains(oneUser); // mParticipantsList.getCheckBoxListModel().addCheckBoxElement( // new UserElement(oneUser), // selected); // } final WebButton saveButton = new WebButton(Tr.tr("Save")); // mParticipantsList.getModel().addListDataListener(new ListDataListener() { // @Override // public void intervalAdded(ListDataEvent e) { // } // @Override // public void intervalRemoved(ListDataEvent e) { // } // @Override // public void contentsChanged(ListDataEvent e) { // saveButton.setEnabled(!mParticipantsList.getCheckedValues().isEmpty()); // } // }); // // groupPanel.add(new WebScrollPane(mParticipantsList)); // groupPanel.add(new WebSeparator(true, true)); this.add(groupPanel, BorderLayout.CENTER); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // if (mParticipantsList.getCheckedValues().size() > 1) { // String infoText = Tr.t/r("More than one receiver not supported (yet)."); // WebOptionPane.showMessageDialog(ThreadListView.this, // infoText, // Tr.t/r("Sorry"), // WebOptionPane.INFORMATION_MESSAGE); // return; // } ThreadDetails.this.save(); // close popup focusGainer.requestFocus(); } }); //this.getRootPane().setDefaultButton(saveButton); GroupPanel buttonPanel = new GroupPanel(2, saveButton); buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:org.executequery.gui.scriptgenerators.GenerateScriptsPanelThree.java
/** * Invoked when the include constraints checkbox has * been selected/deselected.//from w w w .j a va2s . co m */ public void itemStateChanged(ItemEvent e) { enableConstraintChecks(e.getStateChange() == ItemEvent.SELECTED); }