List of usage examples for java.awt.event ItemEvent getItem
public Object getItem()
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createLocationsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;/*from w ww . j a v a2 s . co m*/ JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Working folder")); folderField = new JTextField(); folderField.setText((new File("").getAbsolutePath())); folderField.setToolTipText("The folder where all output will be written"); folderPanel.add(folderField); JButton pickButton = new JButton("Pick folder"); pickButton.setToolTipText("Pick a different working folder"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickFolder(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel sourcePanel = new JPanel(); sourcePanel.setLayout(new GridLayout(0, 2)); sourcePanel.setBorder(BorderFactory.createTitledBorder("Source data location")); sourcePanel.add(new JLabel("Data type")); sourceType = new JComboBox<String>(new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL", "MS Access", "PDW", "Redshift", "Teradata" }); sourceType.setToolTipText("Select the type of source data available"); sourceType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { sourceIsFiles = arg0.getItem().toString().equals("Delimited text files"); sourceServerField.setEnabled(!sourceIsFiles); sourceUserField.setEnabled(!sourceIsFiles); sourcePasswordField.setEnabled(!sourceIsFiles); sourceDatabaseField.setEnabled(!sourceIsFiles); sourceDelimiterField.setEnabled(sourceIsFiles); addAllButton.setEnabled(!sourceIsFiles); if (!sourceIsFiles && arg0.getItem().toString().equals("Oracle")) { sourceServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); sourceUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); sourcePasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); sourceDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!sourceIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { sourceServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!sourceIsFiles) { sourceServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) sourceUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); sourcePanel.add(sourceType); sourcePanel.add(new JLabel("Server location")); sourceServerField = new JTextField("127.0.0.1"); sourceServerField.setEnabled(false); sourcePanel.add(sourceServerField); sourcePanel.add(new JLabel("User name")); sourceUserField = new JTextField(""); sourceUserField.setEnabled(false); sourcePanel.add(sourceUserField); sourcePanel.add(new JLabel("Password")); sourcePasswordField = new JPasswordField(""); sourcePasswordField.setEnabled(false); sourcePanel.add(sourcePasswordField); sourcePanel.add(new JLabel("Database name")); sourceDatabaseField = new JTextField(""); sourceDatabaseField.setEnabled(false); sourcePanel.add(sourceDatabaseField); sourcePanel.add(new JLabel("Delimiter")); sourceDelimiterField = new JTextField(","); sourceDelimiterField.setToolTipText("The delimiter that separates values. Enter 'tab' for tab."); sourcePanel.add(sourceDelimiterField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(sourcePanel, c); JPanel testConnectionButtonPanel = new JPanel(); testConnectionButtonPanel.setLayout(new BoxLayout(testConnectionButtonPanel, BoxLayout.X_AXIS)); testConnectionButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getSourceDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); testConnectionButtonPanel.add(testConnectionButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(testConnectionButtonPanel, c); return panel; }
From source file:sms.Form1Exams.java
private void jComboBoxSubjectsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxSubjectsItemStateChanged cntrltbl();/* ww w.j a v a 2s. c o m*/ if (evt.getItem() != "" && evt.getStateChange() == ItemEvent.SELECTED && evt.getItem() != "Choose Subjects") { subjectin = evt.getItem().toString(); subjectNameToId(subjectin); } else { subjectin = "null"; subjectid = ""; } }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createFakeDataPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;// w w w.jav a 2s . c o m JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file")); scanReportFileField = new JTextField(); scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath())); scanReportFileField.setToolTipText( "The path to the scan report that will be used as a template to generate the fake data"); folderPanel.add(scanReportFileField); JButton pickButton = new JButton("Pick file"); pickButton.setToolTipText("Pick a scan report file"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickScanReportFile(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel targetPanel = new JPanel(); targetPanel.setLayout(new GridLayout(0, 2)); targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location")); targetPanel.add(new JLabel("Data type")); targetType = new JComboBox<String>( new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" }); // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" }); targetType.setToolTipText("Select the type of source data available"); targetType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { targetIsFiles = arg0.getItem().toString().equals("Delimited text files"); targetServerField.setEnabled(!targetIsFiles); targetUserField.setEnabled(!targetIsFiles); targetPasswordField.setEnabled(!targetIsFiles); targetDatabaseField.setEnabled(!targetIsFiles); targetCSVFormat.setEnabled(targetIsFiles); if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) { targetServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); targetUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); targetPasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); targetDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { targetServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!targetIsFiles) { targetServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) targetUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); targetPanel.add(targetType); targetPanel.add(new JLabel("Server location")); targetServerField = new JTextField("127.0.0.1"); targetServerField.setEnabled(false); targetPanel.add(targetServerField); targetPanel.add(new JLabel("User name")); targetUserField = new JTextField(""); targetUserField.setEnabled(false); targetPanel.add(targetUserField); targetPanel.add(new JLabel("Password")); targetPasswordField = new JPasswordField(""); targetPasswordField.setEnabled(false); targetPanel.add(targetPasswordField); targetPanel.add(new JLabel("Database name")); targetDatabaseField = new JTextField(""); targetDatabaseField.setEnabled(false); targetPanel.add(targetDatabaseField); targetPanel.add(new JLabel("CSV Format")); targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)", "MySQL (tab, LF)", "RFC4180", "Excel CSV" }); targetCSVFormat.setToolTipText("The format of the output"); targetCSVFormat.setEnabled(true); targetPanel.add(targetCSVFormat); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(targetPanel, c); JPanel fakeDataButtonPanel = new JPanel(); fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS)); fakeDataButtonPanel.add(new JLabel("Max rows per table")); generateRowCount = new JSpinner(); generateRowCount.setValue(10000); fakeDataButtonPanel.add(generateRowCount); fakeDataButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getTargetDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); fakeDataButtonPanel.add(testConnectionButton); JButton fakeDataButton = new JButton("Generate fake data"); fakeDataButton.setBackground(new Color(151, 220, 141)); fakeDataButton.setToolTipText("Generate fake data based on the scan report"); fakeDataButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fakeDataRun(); } }); componentsToDisableWhenRunning.add(fakeDataButton); fakeDataButtonPanel.add(fakeDataButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(fakeDataButtonPanel, c); return panel; }
From source file:sms.Form1Exams.java
private void jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox2ItemStateChanged cntrltbl();/* ww w . j av a2s . c om*/ String[] terms = { "Term 1", "Term 2", "Term 3" }; if (evt.getItem() == terms[0] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 1; // JOptionPane.showMessageDialog(null, term); } else if (evt.getItem() == terms[1] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 2; // JOptionPane.showMessageDialog(null, term); } else if (evt.getItem() == terms[2] && evt.getStateChange() == ItemEvent.SELECTED) { termid = 3; // JOptionPane.showMessageDialog(null, term); } }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * The itemStateChanged method of the ItemListener interface. * //from ww w. j av a2 s .c o m * @param event The event which triggered this ItemListener. */ public void itemStateChanged(ItemEvent event) { Object source = event.getItem(); try { firePickedVertexChangeEvent((V) source, event.getStateChange() == ItemEvent.SELECTED); } catch (ClassCastException e) { firePickedEdgeChangeEvent((E) source, event.getStateChange() == ItemEvent.SELECTED); } }
From source file:op.care.prescription.PnlScheduleDose.java
private void cmbUhrzeitItemStateChanged(ItemEvent e) { // currentSelectedTime = (Date) e.getItem(); lblTimeDose.setText(SYSTools.xx(internalClassID + ".lblTimeDose") + " " + DateFormat.getTimeInstance(DateFormat.SHORT).format(e.getItem()) + " " + SYSTools.xx("misc.msg.Time.short")); }
From source file:richtercloud.document.scanner.gui.DocumentScanner.java
/** * Creates new DocumentScanner which does nothing unless * * @throws richtercloud.document.scanner.gui.TesseractNotFoundException *///from w ww.j a va2 s. c o m /* internal implementation notes: - resources are opened in init methods only (see https://richtercloud.de:446/doku.php?id=programming:java#resource_handling for details) */ public DocumentScanner() throws BinaryNotFoundException { this.parseArguments(); assert HOME_DIR.exists(); if (!CONFIG_DIR.exists()) { CONFIG_DIR.mkdir(); LOGGER.info("created inexisting configuration directory '{}'", CONFIG_DIR_NAME); } try { this.tesseractOCREngineConfPanel = new TesseractOCREngineConfPanel(); } catch (IOException | InterruptedException ex) { throw new RuntimeException(ex); } this.initComponents(); //loading properties depends on initComponents because exceptions are //handled with GUI elements this.configFile = new File(CONFIG_DIR, CONFIG_FILE_NAME); if (this.configFile.exists()) { this.loadProperties(); //initializes this.conf } else { try { this.documentScannerConf = new DocumentScannerConf(entityManager, messageHandler, ENTITY_CLASSES, derbyPersistenceStorageSchemeChecksumFile, xMLStorageFile); } catch (IOException ex) { throw new RuntimeException(ex); } LOGGER.info("no previous configuration found in configuration directry '{}', using default values", CONFIG_DIR.getAbsolutePath()); //new configuration will be persisted in shutdownHook } //after loading DocumentScannerConf for (StorageConf<?, ?> availableStorageConf : this.documentScannerConf.getAvailableStorageConfs()) { this.storageListModel.addElement(availableStorageConf); } this.onDeviceUnset(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LOGGER.info("running {} shutdown hooks", DocumentScanner.class); DocumentScanner.this.shutdownHook(); } }); this.oCREngineConfPanelMap.put(TesseractOCREngineConf.class, this.tesseractOCREngineConfPanel); this.oCREngineComboBoxModel.addElement(TesseractOCREngineConf.class); this.oCRDialogEngineComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Class<? extends OCREngineConf<?>> clazz = (Class<? extends OCREngineConf<?>>) e.getItem(); OCREngineConfPanel<?> cREngineConfPanel = DocumentScanner.this.oCREngineConfPanelMap.get(clazz); DocumentScanner.this.oCRDialogPanel.removeAll(); DocumentScanner.this.oCRDialogPanel.add(cREngineConfPanel); DocumentScanner.this.oCRDialogPanel.revalidate(); DocumentScanner.this.pack(); DocumentScanner.this.oCRDialogPanel.repaint(); } }); this.oCRDialogPanel.setLayout(new BoxLayout(this.oCRDialogPanel, BoxLayout.X_AXIS)); //set initial panel state this.oCRDialogPanel.removeAll(); this.oCRDialogPanel.add(this.tesseractOCREngineConfPanel); this.oCRDialogPanel.revalidate(); this.pack(); this.oCRDialogPanel.repaint(); this.storageCreateDialogTypeComboBoxModel.addElement(DerbyPersistenceStorageConf.class); this.storageCreateDialogTypeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Class<? extends StorageConf<?, ?>> clazz = (Class<? extends StorageConf<?, ?>>) e.getItem(); StorageConfPanel<?> storageConfPanel = DocumentScanner.this.storageConfPanelMap.get(clazz); DocumentScanner.this.storageCreateDialogPanel.removeAll(); DocumentScanner.this.storageCreateDialogPanel.add(storageConfPanel); DocumentScanner.this.storageCreateDialogPanel.revalidate(); DocumentScanner.this.pack(); DocumentScanner.this.storageCreateDialogPanel.repaint(); } }); this.storageList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DocumentScanner.this.storageDialogSelectButton .setEnabled(DocumentScanner.this.storageListModel.getSize() > 0 && DocumentScanner.this.storageList.getSelectedIndices().length > 0); } }); File amountMoneyUsageStatisticsStorageFile = new File(CONFIG_DIR, AMOUNT_MONEY_USAGE_STATISTICS_STORAGE_FILE_NAME); File amountMoneyCurrencyStorageFile = new File(CONFIG_DIR, AMOUNT_MONEY_CURRENCY_STORAGE_FILE_NAME); try { this.amountMoneyUsageStatisticsStorage = new FileAmountMoneyUsageStatisticsStorage( amountMoneyUsageStatisticsStorageFile); } catch (IOException ex) { throw new RuntimeException(ex); } this.amountMoneyCurrencyStorage = new FileAmountMoneyCurrencyStorage(amountMoneyCurrencyStorageFile); JPAAmountMoneyMappingTypeHandlerFactory fieldHandlerFactory = new JPAAmountMoneyMappingTypeHandlerFactory( entityManager, INITIAL_QUERY_LIMIT_DEFAULT, messageHandler, BIDIRECTIONAL_HELP_DIALOG_TITLE); this.typeHandlerMapping = fieldHandlerFactory.generateTypeHandlerMapping(); //after entity manager creation this.typeHandlerMapping.put(new TypeToken<List<AnyType>>() { }.getType(), new JPAEntityListTypeHandler(entityManager, messageHandler, BIDIRECTIONAL_HELP_DIALOG_TITLE)); }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
/** * initialize LayoutCombox// w w w . j a v a 2 s . co m * * @return */ private JComboBox getLayoutComboBox() { if (layoutBox == null) { layoutBox = new JComboBox(new LayoutType[] { LayoutType.FRLayout, LayoutType.EWLayout }); layoutBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutType layoutType = (LayoutType) e.getItem(); setLayout(layoutType); } } }); } layoutBox.setSelectedItem(LayoutType.FRLayout); return layoutBox; }
From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
/** * initialize LayoutMenu/*from ww w. jav a 2 s .c o m*/ * * @return */ private JMenu getLayoutMenu() { if (layoutMenu == null) { layoutMenu = new JMenu(); final JRadioButtonMenuItem frButton = new JRadioButtonMenuItem(LayoutType.FRLayout.toString()); final JRadioButtonMenuItem ewButton = new JRadioButtonMenuItem(LayoutType.EWLayout.toString()); ItemListener layoutMenuItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem().equals(frButton)) { setLayout(LayoutType.FRLayout); layoutBox.setSelectedItem(LayoutType.FRLayout); } else if (e.getItem().equals(ewButton)) { setLayout(LayoutType.EWLayout); layoutBox.setSelectedItem(LayoutType.EWLayout); } } } }; frButton.addItemListener(layoutMenuItemListener); ewButton.addItemListener(layoutMenuItemListener); ButtonGroup radio = new ButtonGroup(); radio.add(frButton); radio.add(ewButton); frButton.setSelected(true); layoutMenu.add(frButton); layoutMenu.add(ewButton); layoutMenu.setToolTipText("Menu for setting graph layout"); // layoutMenu.addItemListener(layoutMenuItemListener); layoutBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem().equals(LayoutType.FRLayout)) { frButton.setSelected(true); } else if (e.getItem().equals(LayoutType.EWLayout)) { ewButton.setSelected(true); } } } }); } return layoutMenu; }
From source file:mesquite.zephyr.lib.GarliRunner.java
public void itemStateChanged(ItemEvent e) { if (charPartitionButtons.isAButton(e.getItemSelectable())) { // button for the partition scheme processCharacterModels();/*w w w .j a v a2 s . c o m*/ if (charPartitionButtons != null) partitionScheme = charPartitionButtons.getValue(); if (partitionChoice != null) preparePartitionChoice(partitionChoice, partitionScheme); } else if (e.getItemSelectable() == partitionChoice) { // popup for which partition to edit processCharacterModels(); if (partitionScheme == partitionByCodonPosition) { if (codpos1Subset.equalsIgnoreCase((String) e.getItem())) { currentPartitionSubset = 0; setCharacterModels(); } else if (codpos2Subset.equalsIgnoreCase((String) e.getItem())) { currentPartitionSubset = 1; setCharacterModels(); } else if (codpos3Subset.equalsIgnoreCase((String) e.getItem())) { currentPartitionSubset = 2; setCharacterModels(); } else if (nonCodingSubset.equalsIgnoreCase((String) e.getItem())) { currentPartitionSubset = 3; setCharacterModels(); } } else if (partitionScheme == partitionByCharacterGroups) { currentPartitionSubset = ZephyrUtil.getPartitionSubset(data, (String) e.getItem()); setCharacterModels(); } else setCharacterModels(); } else if (e.getItemSelectable() == constraintButtons && constraintButtons.getValue() > 0) { getConstraintTreeSource(); } else if (e.getItemSelectable() == rateMatrixChoice) { if (data instanceof ProteinData) { } else { String matrix = ""; int choiceValue = rateMatrixChoice.getSelectedIndex(); switch (choiceValue) { case 0: matrix = "1rate"; break; case 1: matrix = "2rate"; break; case 2: matrix = "6rate"; break; case 3: // Custom if (customMatrix != null) { matrix = customMatrix.getText(); if (matrix == null || "1rate 2rate 6rate".indexOf(matrix) >= 0) // Debugg.println keep previous custom matrices remembered for users who switch back to them? matrix = "(a a a a a a)"; } break; default: matrix = "6rate"; } if (customMatrix != null) { customMatrix.setText(matrix); if (choiceValue == 3) { customMatrix.setEditable(true); customMatrix.setBackground(Color.white); } else { customMatrix.setEditable(false); customMatrix.setBackground(ColorDistribution.veryLightGray); } } } } else if (e.getItemSelectable() == doBootstrapCheckbox) { checkEnabled(doBootstrapCheckbox.getState()); } }