List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:iqq.app.ui.module.UILoginModule.java
/** * ??// w ww . j a va 2 s . co m */ private void initAccount() { WebComboBox accoutCbx = (WebComboBox) getValue("account"); final WebPasswordField passwordFld = (WebPasswordField) getValue("password"); StatusPopup statusPopup = (StatusPopup) getValue("status"); WebCheckBox rePwdCkb = (WebCheckBox) getValue("rememberPwd"); // ? rePwdCkb.setSelected(true); statusPopup.setCurrentStatus(QQStatus.ONLINE); accoutCbx.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getItem() instanceof UserListElement) { UserListElement userElt = (UserListElement) e.getItem(); QQAccount account = (QQAccount) userElt.getUserNamed().getEntity(); passwordFld.setText(account.getPassword()); } else { passwordFld.clear(); } } }); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.PopulationFitnessView.java
/** * Creates the GUI controls for toggling graph display options. * @return A component that can be added to the main panel. *///from ww w. j a v a 2 s . c o m private JComponent createControls(boolean islands) { JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); allDataButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { updateDomainAxisRange(); } }); String text = "Last " + SHOW_FIXED_GENERATIONS + (islands ? " Epochs" : " Generations"); JRadioButton recentDataButton = new JRadioButton(text, true); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(allDataButton); buttonGroup.add(recentDataButton); controls.add(allDataButton); controls.add(recentDataButton); final JCheckBox meanCheckBox = new JCheckBox("Show Mean", true); meanCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { dataSet.addSeries(meanSeries); } else { dataSet.removeSeries(meanSeries); } } }); controls.add(meanCheckBox); invertCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { rangeAxis.setInverted(invertCheckBox.isSelected()); } }); controls.add(invertCheckBox); return controls; }
From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java
/** * Creates new form DSWorkbenchDistanceFrame *//*from www .j a va 2 s . c o m*/ DSWorkbenchDistanceFrame() { initComponents(); centerPanel = new GenericTestPanel(true); jDistancePanel.add(centerPanel, BorderLayout.CENTER); centerPanel.setChildComponent(jPanel2); unitBox = new JComboBox(); unitBox.setRenderer(new UnitListCellRenderer()); unitBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cellRenderer.setUnit((UnitHolder) unitBox.getSelectedItem()); jDistanceTable.repaint(); } }); buildMenu(); jDistanceTable.setModel(new DistanceTableModel()); KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false); capabilityInfoPanel1.addActionListener(this); jDistanceTable.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DSWorkbenchDistanceFrame.getSingleton() .actionPerformed(new ActionEvent(jDistanceTable, 0, "Delete")); } }, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jDistanceTable.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DSWorkbenchDistanceFrame.getSingleton() .actionPerformed(new ActionEvent(jDistanceTable, 0, "Paste")); } }, "Paste", paste, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); jDistanceTable.getActionMap().put("find", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { //disable find } }); jDistanceTable.getSelectionModel().addListSelectionListener(DSWorkbenchDistanceFrame.this); cellRenderer.setUnit(UnknownUnit.getSingleton()); // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem "> if (!Constants.DEBUG) { GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.distance_overview", GlobalOptions.getHelpBroker().getHelpSet()); } // </editor-fold> }
From source file:Store.SelectedPatient.java
public SelectedPatient() { initComponents();/* w w w . j a v a 2 s.co m*/ conn = DBConnection.ConnecrDB(); TableUpdateP(); TableUpdateT(); // CurrentDateAndTime(); // restrict selectable date to the current day p_d.setMaxSelectableDate(new java.util.Date()); Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Store/icons/H-2-icon.png")); setIconImage(img); tr_by.setText(holdNames); // populate the disease and type combobox try { String loggedin = Empnumber.getEno2(); String sql = "select * from doctors where Doc_No = '" + loggedin + "' "; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String d = rs.getString("Specialization"); String t = rs.getString("type"); combo_co.addItem(d); combo_ty.addItem(t); } } catch (Exception e) { } String ptt = "Patient: " + namef.getText() + " " + namel.getText(); lb_pn.setText(ptt); //Handle County and sub-county Selection p_a.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { String county = p_a.getSelectedItem().toString().trim(); if (county.equalsIgnoreCase("Kakamega")) { subcombo.removeAllItems(); subcombo.addItem("Lurambi"); subcombo.addItem("Lugari"); subcombo.addItem("Likunyani"); subcombo.addItem("Navakholo"); subcombo.addItem("Butere"); subcombo.addItem("Mumias East"); subcombo.addItem("Mumias West"); subcombo.addItem("Matungu"); subcombo.addItem("Khwisero"); subcombo.addItem("Ikolomani"); subcombo.addItem("Malava"); subcombo.addItem("Shinyalu"); } else { subcombo.removeAllItems(); subcombo.addItem("Wamumu"); subcombo.addItem("Thiba"); subcombo.addItem("Nyangati"); subcombo.addItem("Mahigaini"); subcombo.addItem("Mutithi"); subcombo.addItem("Nguka"); subcombo.addItem("Kutus"); subcombo.addItem("Karira"); } } catch (Exception e1) { } } }); }
From source file:op.care.med.inventory.DlgOpenStock.java
/** * This method is called from within the constructor to * initialize the form./*from w ww. j a v a2 s. c om*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { lbl1 = new JLabel(); cmbBestID = new JComboBox<>(); lbl2 = new JLabel(); btnClose = new JButton(); btnOK = new JButton(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setResizable(false); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout( "default, $lcgap, default:grow, 2*($lcgap, default), $lcgap, default:grow, $lcgap, default", "default, $lgap, fill:default, 21dlu, default, $lgap, default")); //---- lbl1 ---- lbl1.setText("Die Packung mit der Nummer:"); lbl1.setFont(new Font("Arial", Font.PLAIN, 14)); contentPane.add(lbl1, CC.xy(3, 3)); //---- cmbBestID ---- cmbBestID.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cmbBestID.setFont(new Font("Arial", Font.PLAIN, 14)); cmbBestID.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cmbBestIDItemStateChanged(e); } }); contentPane.add(cmbBestID, CC.xy(5, 3)); //---- lbl2 ---- lbl2.setText("anbrechen."); lbl2.setFont(new Font("Arial", Font.PLAIN, 14)); contentPane.add(lbl2, CC.xywh(7, 3, 3, 1)); //---- btnClose ---- btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png"))); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCloseActionPerformed(e); } }); contentPane.add(btnClose, CC.xy(7, 5)); //---- btnOK ---- btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png"))); btnOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnOKActionPerformed(e); } }); contentPane.add(btnOK, CC.xy(9, 5)); setSize(455, 165); setLocationRelativeTo(getOwner()); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.IslandsView.java
/** * Creates the GUI controls for toggling graph display options. * @return A component that can be added to the main panel. *///from w w w . j a v a2 s. c om private JComponent createControls() { JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox meanCheckBox = new JCheckBox("Show Mean and Standard Deviation", false); meanCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { chart.setNotify(false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); if (itemEvent.getStateChange() == ItemEvent.SELECTED) { plot.setDataset(1, meanDataSet); plot.setRenderer(1, meanRenderer); } else { plot.setDataset(1, null); plot.setRenderer(1, null); } chart.setNotify(true); } }); controls.add(meanCheckBox); return controls; }
From source file:net.pms.newgui.GeneralTab.java
public JComponent build() { // Apply the orientation for the locale Locale locale = new Locale(configuration.getLanguage()); ComponentOrientation orientation = ComponentOrientation.getOrientation(locale); String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.DLU4_BORDER); builder.setOpaque(true);/*from w w w.ja v a 2 s . co m*/ CellConstraints cc = new CellConstraints(); smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3")); smcheckBox.setContentAreaFilled(false); smcheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMinimized((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isMinimized()) { smcheckBox.setSelected(true); } JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, 1, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("NetworkTab.0"), FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); final KeyedComboBoxModel kcbm = new KeyedComboBoxModel( new Object[] { "ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "iw", "is", "it", "ja", "ko", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv", "tr" }, new Object[] { "Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Hebrew", "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish", "Turkish" }); langs = new JComboBox(kcbm); langs.setEditable(false); String defaultLang = null; if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) { defaultLang = configuration.getLanguage(); } else { defaultLang = Locale.getDefault().getLanguage(); } if (defaultLang == null) { defaultLang = "en"; } kcbm.setSelectedKey(defaultLang); if (langs.getSelectedIndex() == -1) { langs.setSelectedIndex(0); } langs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setLanguage((String) kcbm.getSelectedKey()); } } }); builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation)); builder.add(smcheckBox, FormLayoutUtil.flip(cc.xyw(1, 9, 9), colSpec, orientation)); JButton service = new JButton(Messages.getString("NetworkTab.4")); service.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (PMS.get().installWin32Service()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.14"), Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } } }); builder.add(service, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation)); if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) { service.setEnabled(false); } JButton checkForUpdates = new JButton(Messages.getString("NetworkTab.8")); checkForUpdates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LooksFrame frame = (LooksFrame) PMS.get().getFrame(); frame.checkForUpdates(); } }); builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation)); autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9")); autoUpdateCheckBox.setContentAreaFilled(false); autoUpdateCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isAutoUpdate()) { autoUpdateCheckBox.setSelected(true); } builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(7, 13, 3), colSpec, orientation)); if (!Build.isUpdatable()) { checkForUpdates.setEnabled(false); autoUpdateCheckBox.setEnabled(false); } host = new JTextField(configuration.getServerHostname()); host.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setHostname(host.getText()); } }); port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : ""); port.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { try { String p = port.getText(); if (StringUtils.isEmpty(p)) { p = "5001"; } int ab = Integer.parseInt(p); configuration.setServerPort(ab); } catch (NumberFormatException nfe) { logger.debug("Could not parse port from \"" + port.getText() + "\""); } } }); cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), FormLayoutUtil.flip(cc.xyw(1, 21, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel(); networkinterfacesCBX = new JComboBox(networkInterfaces); networkInterfaces.setSelectedKey(configuration.getNetworkInterface()); networkinterfacesCBX.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey()); } } }); ip_filter = new JTextField(configuration.getIpFilter()); ip_filter.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setIpFilter(ip_filter.getText()); } }); maxbitrate = new JTextField(configuration.getMaximumBitrate()); maxbitrate.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { PMS.getConfiguration().setMaximumBitrate(maxbitrate.getText()); } }); builder.addLabel(Messages.getString("NetworkTab.20"), FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation)); builder.add(networkinterfacesCBX, FormLayoutUtil.flip(cc.xyw(3, 23, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.23"), FormLayoutUtil.flip(cc.xy(1, 25), colSpec, orientation)); builder.add(host, FormLayoutUtil.flip(cc.xyw(3, 25, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.24"), FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation)); builder.add(port, FormLayoutUtil.flip(cc.xyw(3, 27, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.30"), FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation)); builder.add(ip_filter, FormLayoutUtil.flip(cc.xyw(3, 29, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.35"), FormLayoutUtil.flip(cc.xy(1, 31), colSpec, orientation)); builder.add(maxbitrate, FormLayoutUtil.flip(cc.xyw(3, 31, 7), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), FormLayoutUtil.flip(cc.xyw(1, 33, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32")); newHTTPEngine.setSelected(configuration.isHTTPEngineV2()); newHTTPEngine.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(newHTTPEngine, FormLayoutUtil.flip(cc.xyw(1, 35, 9), colSpec, orientation)); preventSleep = new JCheckBox(Messages.getString("NetworkTab.33")); preventSleep.setSelected(configuration.isPreventsSleep()); preventSleep.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(preventSleep, FormLayoutUtil.flip(cc.xyw(1, 37, 9), colSpec, orientation)); JCheckBox fdCheckBox = new JCheckBox(Messages.getString("NetworkTab.38")); fdCheckBox.setContentAreaFilled(false); fdCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setRendererForceDefault((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isRendererForceDefault()) { fdCheckBox.setSelected(true); } builder.addLabel(Messages.getString("NetworkTab.36"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation)); ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getAllRendererConfigurations(); ArrayList<Object> keyValues = new ArrayList<Object>(); ArrayList<Object> nameValues = new ArrayList<Object>(); keyValues.add(""); nameValues.add(Messages.getString("NetworkTab.37")); if (allConfs != null) { for (RendererConfiguration renderer : allConfs) { if (renderer != null) { keyValues.add(renderer.getRendererName()); nameValues.add(renderer.getRendererName()); } } } final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel( (Object[]) keyValues.toArray(new Object[keyValues.size()]), (Object[]) nameValues.toArray(new Object[nameValues.size()])); renderers = new JComboBox(renderersKcbm); renderers.setEditable(false); String defaultRenderer = configuration.getRendererDefault(); renderersKcbm.setSelectedKey(defaultRenderer); if (renderers.getSelectedIndex() == -1) { renderers.setSelectedIndex(0); } builder.add(renderers, FormLayoutUtil.flip(cc.xyw(3, 39, 7), colSpec, orientation)); builder.add(fdCheckBox, FormLayoutUtil.flip(cc.xyw(1, 41, 9), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), FormLayoutUtil.flip(cc.xyw(1, 43, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); pPlugins = new JPanel(new GridLayout()); builder.add(pPlugins, FormLayoutUtil.flip(cc.xyw(1, 45, 9), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); return scrollPane; }
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. j a va 2s .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.zaproxy.zap.extension.reveal.ExtensionReveal.java
private JToggleButton getRevealButton() { if (revealButton == null) { revealButton = new ZapToggleButton(); revealButton.setIcon(new ImageIcon(ExtensionReveal.class.getResource("resources/icons/044.png"))); // 'light off' icon revealButton.setToolTipText(Constant.messages.getString("reveal.button.enable")); revealButton//from w w w . j av a2 s. c o m .setSelectedIcon(new ImageIcon(ExtensionReveal.class.getResource("resources/icons/043.png"))); // 'light on' icon revealButton.setSelectedToolTipText(Constant.messages.getString("reveal.button.disable")); revealButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setReveal(ItemEvent.SELECTED == e.getStateChange()); } }); } return revealButton; }
From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java
private void buildUI() { setLayout(new GridBagLayout()); final DBViewer viewer = Globals.getDBViewer(); schemaCombo = new JComboBox(); schemaCombo.setPreferredSize(comboDim); schemaCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { String schema = (String) e.getItem(); shownColumnModel.clear();//from w w w . j a v a 2 s . c om columnModel.clear(); tableModel.clear(); try { DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS); List<DBTable> tables = dbInfo.getTables(); Collections.sort(tables); for (DBTable table : tables) { tableModel.addElement(table); } } catch (NextSqlException ex) { LOG.error(ex.getMessage(), ex); ex.printStackTrace(); } } }); try { List<String> schemas = viewer.getSchemas(); String schemaName = viewer.getUserSchema(); Collections.sort(schemas); boolean added = false; for (String schema : schemas) { if (DefaultSchemaManager.getInstance().isVisible( DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) { added = true; schemaCombo.addItem(schema); } } if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) { schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema(); } if (!added) { schemaCombo.addItem(schema); } schemaCombo.setSelectedItem(schema); } catch (NextSqlException e) { LOG.error(e.getMessage(), e); e.printStackTrace(); } // create table list tableList = new JXList(tableModel); tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tableList.setCellRenderer(new DBTableCellRenderer()); // create column list columnList = new JXList(columnModel); if (singleSelection) { columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } columnList.setCellRenderer(new DBColumnCellRenderer()); shownColumnList = new JXList(shownColumnModel); if (singleSelection) { shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else { columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } addDoubleClick(); shownColumnList.setCellRenderer(new DBColumnCellRenderer()); shownColumnList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent mouseEvent) { if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList)); popupMenu.add(menuItem); popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY()); } } }); tableList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { int index = tableList.getSelectedIndex(); if (index == -1) { return; } DBTable table = (DBTable) tableModel.getElementAt(index); try { List<DBColumn> columns = null; try { columns = viewer.getColumns(table.getSchema(), table.getName()); } catch (MalformedTableNameException e1) { Show.error("Malformed table name : " + table.getName()); return; } Collections.sort(columns); columnModel.clear(); shownColumnModel.clear(); for (DBColumn column : columns) { columnModel.addElement(column); shownColumnModel.addElement(column); } } catch (NextSqlException e1) { LOG.error(e1.getMessage(), e1); e1.printStackTrace(); Show.error(e1); } } } }); columnList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { shownColumnList.clearSelection(); } }); scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrTable.setPreferredSize(scrDim); scrTable.setMinimumSize(scrDim); scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables"))); scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrColumn.setPreferredSize(scrDim); scrColumn.setMinimumSize(scrDim); scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns"))); scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrShownColumn.setPreferredSize(scrDim); scrShownColumn.setMinimumSize(scrDim); scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns"))); JPanel schemaPanel = new JPanel(); schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS)); schemaPanel.add(new JLabel("Schema")); schemaPanel.add(Box.createHorizontalStrut(5)); schemaPanel.add(schemaCombo); add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); if (show) { add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } }