List of usage examples for javax.swing DefaultComboBoxModel DefaultComboBoxModel
public DefaultComboBoxModel(Vector<E> v)
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private int FillEntryComboBox(JComboBox comboBox, int id) { int result = -1; List<Entry> allEntrys = this.entryService.GetAllEntities(); if (allEntrys.size() > 0) { List<Entry> entrys = allEntrys.stream().filter(x -> x.getInUse().equals("YES")) .collect(Collectors.toList()); if (entrys.size() > 0) { List<ComboBoxItem<Entry>> entryNames = entrys.stream().sorted(comparing(x -> x.getCreateDate())) .map(x -> ComboBoxItemConvertor.ConvertToComboBoxItem(x, (x.getMachineId() != null ? x.getMachineId().getMachineNo() : "") + "/" + (x.getProductId() != null ? x.getProductId().getCode() : ""), x.getId()))/* w ww . ja v a 2s . c o m*/ .collect(Collectors.toList()); Entry entry = new Entry(); entry.setId(0); entry.setShift("- Select -"); entryNames.add(0, new ComboBoxItem<Entry>(entry, entry.getShift(), entry.getId())); ComboBoxItem[] entryNamesArray = entryNames.toArray(new ComboBoxItem[entryNames.size()]); comboBox.setModel(new DefaultComboBoxModel(entryNamesArray)); if (id != 0) { ComboBoxItem<Entry> currentEntryName = entryNames.stream().filter(x -> x.getId() == id) .findFirst().get(); result = entryNames.indexOf(currentEntryName); this.currentEntry = ((ComboBoxItem<Entry>) comboBox.getSelectedItem()).getItem(); } else { result = 0; } comboBox.setSelectedIndex(result); } } return result; }
From source file:com.proyecto.vista.MantenimientoAmbiente.java
private void cargarComboArea() { AreaControlador ac = new AreaControlador(); List<Area> area = ac.buscarTodos(); cmbArea.setModel(new DefaultComboBoxModel(area.toArray())); AutoCompleteDecorator.decorate(this.cmbArea); }
From source file:com.raddle.tools.MergeMain.java
private void compare() { if (source != null && target != null) { // source sourceList.setModel(new DefaultComboBoxModel(diffLines(source, target).toArray())); // target targetList.setModel(new DefaultComboBoxModel(diffLines(target, source).toArray())); } else if (source != null) { sourceList.setModel(new DefaultComboBoxModel(source.getProperties().toArray())); } else if (target != null) { targetList.setModel(new DefaultComboBoxModel(target.getProperties().toArray())); }//from w ww .j av a2s . c om }
From source file:jeplus.gui.JPanel_TrnsysProjectFiles.java
private void cmdEditRVIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditRVIActionPerformed // Test if the template file is present String fn = (String) cboRviFile.getSelectedItem(); if (fn.startsWith("Select ")) { fn = "my.rvx"; }//from ww w . j a v a 2 s .c om String templfn = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText() + fn, Project.getBaseDir()); File ftmpl = new File(templfn); if (!ftmpl.exists()) { int n = JOptionPane.showConfirmDialog(this, "<html><p><center>" + templfn + " does not exist." + "Do you want to copy one from an existing file?</center></p>" + "<p> Alternatively, select 'NO' to create this file. </p>", "RVI file not available", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { // Select a file to open if (this.chkReadVar.isSelected()) { MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVX)); } else { MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVI)); } MainGUI.getFileChooser().setMultiSelectionEnabled(false); MainGUI.getFileChooser().setSelectedFile(new File("")); String rvidir = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText(), Project.getBaseDir()); MainGUI.getFileChooser().setCurrentDirectory(new File(rvidir)); if (MainGUI.getFileChooser().showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File file = MainGUI.getFileChooser().getSelectedFile(); try { FileUtils.copyFile(file, new File(templfn)); cboRviFile.setModel(new DefaultComboBoxModel(new String[] { fn })); Project.setRVIDir(txtRviDir.getText()); Project.setRVIFile(fn); } catch (IOException ex) { logger.error("Error copying RVX from source.", ex); } } MainGUI.getFileChooser().resetChoosableFileFilters(); MainGUI.getFileChooser().setSelectedFile(new File("")); } else if (n == JOptionPane.NO_OPTION) { } else { return; } } int idx = MainGUI.getTpnEditors().indexOfTab(fn); if (idx >= 0) { MainGUI.getTpnEditors().setSelectedIndex(idx); } else { EPlusEditorPanel RviFilePanel; if (FilenameUtils.getExtension(fn).equals("rvx")) { RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn, EPlusEditorPanel.FileType.RVX, null); } else { RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn, EPlusEditorPanel.FileType.RVI, null); } int ti = MainGUI.getTpnEditors().getTabCount(); MainGUI.getTpnEditors().addTab(fn, RviFilePanel); RviFilePanel.setTabId(ti); MainGUI.getTpnEditors().setSelectedIndex(ti); MainGUI.getTpnEditors().setTabComponentAt(ti, new ButtonTabComponent(MainGUI.getTpnEditors(), RviFilePanel)); MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn); } }
From source file:jeplus.gui.JPanel_EPlusProjectFiles.java
private void cmdSelectRVIFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdSelectRVIFileActionPerformed // Select a file to open if (this.chkReadVar.isSelected()) { MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVX)); } else {//from w w w . j av a2 s . co m MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVI)); } MainGUI.getFileChooser().setMultiSelectionEnabled(false); MainGUI.getFileChooser().setSelectedFile(new File("")); String rvidir = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText(), Project.getBaseDir()); MainGUI.getFileChooser().setCurrentDirectory(new File(rvidir)); if (MainGUI.getFileChooser().showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File file = MainGUI.getFileChooser().getSelectedFile(); String dir = file.getParent() + File.separator; String reldir = RelativeDirUtil.getRelativePath(dir, Project.getBaseDir(), "/"); txtRviDir.setText(reldir); String name = file.getName(); cboRviFile.setModel(new DefaultComboBoxModel(new String[] { name })); Project.setRVIDir(reldir); Project.setRVIFile(name); } MainGUI.getFileChooser().resetChoosableFileFilters(); MainGUI.getFileChooser().setSelectedFile(new File("")); }
From source file:com.ibm.soatf.gui.SOATestingFrameworkGUI.java
private void initEnvironments() { String[] environments = getListOfEnvironments(); if (isEmpty(environments)) { return;//from w w w .ja va 2s . co m } final DefaultComboBoxModel model = new DefaultComboBoxModel(environments); cbEnvironment.setModel(model); final String lastEnv = UserProperties.getLastEnv(); if (isEmpty(lastEnv)) { cbEnvironment.setSelectedIndex(0); } else { cbEnvironment.setSelectedItem(lastEnv); } }
From source file:com.all.login.view.NewAccountFormPanel.java
public void internationalize(Messages messages) { getDisclaimerPanel().internationalize(messages); securityLabel.setText(messages.getMessage("createNewAccount.securityLabel") + messages.getMessage("createNewAccount.securityLabel.empty")); titleLabel.setText(messages.getMessage("createNewAccount.title")); emailLabel.setText(messages.getMessage("createNewAccount.emailLabel")); passwordLabel.setText(messages.getMessage("createNewAccount.passwordLabel")); acceptConditionsCheckBox.setText(messages.getMessage("createNewAccount.acceptTerms")); signUpButton.setText(messages.getMessage("createNewAccount.create")); maxCharacterLabel.setText(messages.getMessage("createNewAccount.maxCharacterLabel")); aboutUsLabel.setText(messages.getMessage("createNewAccount.abooutUsLabel")); nickNameLabel.setText(messages.getMessage("createNewAccount.nickNameLabel")); aboutList = new ArrayList<String>(); aboutList.add(messages.getMessage("aboutUs.default")); aboutList.add(messages.getMessage("aboutUs.suggestion")); aboutList.add(messages.getMessage("aboutUs.flyers")); aboutList.add(messages.getMessage("aboutUs.techtalks")); aboutList.add(messages.getMessage("aboutUs.website")); aboutList.add(messages.getMessage("aboutUs.download.sites")); aboutList.add(messages.getMessage("aboutUs.search.engines")); aboutUsComboBox.setModel(new DefaultComboBoxModel(aboutList.toArray())); this.setName(messages.getMessage("login.NewAccountFormPanel.name")); this.invalidate(); this.revalidate(); }
From source file:jeplus.gui.JPanel_EPlusProjectFiles.java
private void cmdSelectWeatherFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdSelectWeatherFileActionPerformed // Select a file to open MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.EPW)); MainGUI.getFileChooser().setMultiSelectionEnabled(true); MainGUI.getFileChooser().setSelectedFile(new File("")); String wdir = RelativeDirUtil.checkAbsolutePath(txtWthrDir.getText(), Project.getBaseDir()); MainGUI.getFileChooser().setCurrentDirectory(new File(wdir)); if (MainGUI.getFileChooser().showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File[] files = MainGUI.getFileChooser().getSelectedFiles(); String dir = files[0].getParent() + File.separator; String reldir = RelativeDirUtil.getRelativePath(dir, Project.getBaseDir(), "/"); txtWthrDir.setText(reldir);//from w ww . ja v a 2 s. c om String[] names = new String[files.length]; names[0] = files[0].getName(); String namestr = files[0].getName(); for (int i = 1; i < files.length; i++) { names[i] = files[i].getName(); namestr = namestr + "; " + names[i]; } cboWeatherFile.setModel(new DefaultComboBoxModel(names)); Project.setWeatherDir(reldir); Project.setWeatherFile(namestr); } MainGUI.getFileChooser().resetChoosableFileFilters(); MainGUI.getFileChooser().setSelectedFiles(null); }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
/** * Setup attack frame (clear entries, fill lists and set initial values) *///from ww w. j a v a 2s. c o m protected void setup() { // <editor-fold defaultstate="collapsed" desc=" Attack table setup "> DefaultTableModel attackModel = new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Herkunft", "Einheit", "Fake", "Anwendbar" }) { private Class[] types = new Class[] { Village.class, UnitHolder.class, Boolean.class, Integer.class }; @Override public Class getColumnClass(int columnIndex) { return types[columnIndex]; } @Override public boolean isCellEditable(int row, int column) { return (column == 1 || column == 2); } }; jSourcesTable.setModel(attackModel); // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Victim table setup "> DefaultTableModel victimModel = new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Spieler", "Dorf", "Fake", "Angriffe", "Anwendbar" }) { private Class[] types = new Class[] { Tribe.class, Village.class, Boolean.class, Integer.class, Integer.class }; @Override public Class getColumnClass(int columnIndex) { return types[columnIndex]; } @Override public boolean isCellEditable(int row, int column) { return (column == 2 || column == 3); } }; jVictimTable.setModel(victimModel); // </editor-fold> dataChangedEvent(); filterDialog.reset(); String prop = GlobalOptions.getProperty("attack.planer.enable.check"); if (prop != null) { jEnableWarnBox.setSelected(Boolean.parseBoolean(prop)); } else { jEnableWarnBox.setSelected(true); } try { prop = GlobalOptions.getProperty("attack.planer.check.amount"); //check for valid value Integer.parseInt(prop); jTextField1.setText(prop); } catch (Exception e) { jTextField1.setText("20000"); } jSourcesTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); jVictimTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer()); String[] cols = new String[] { "Einheit", "Fake", "Anwendbar" }; for (String col : cols) { TableColumnExt columns = jSourcesTable.getColumnExt(col); columns.setPreferredWidth(80); columns.setMaxWidth(80); columns.setWidth(80); } cols = new String[] { "Fake", "Angriffe", "Anwendbar" }; for (String col : cols) { TableColumnExt columns = jVictimTable.getColumnExt(col); columns.setPreferredWidth(80); columns.setMaxWidth(80); columns.setWidth(80); } jSourcesTable.setHighlighters( HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)); jVictimTable.setHighlighters( HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)); jResultsTable.setHighlighters( HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B)); jAttackPlanSelectionDialog.pack(); try { // <editor-fold defaultstate="collapsed" desc=" Build target allies list "> fireTargetAllyFilterChangedEvent(null); //select first ally and initialize all lists jTargetAllyList.setSelectedIndex(0); // </editor-fold> mSettingsPanel.reset(); AlternatingColorCellRenderer rend = new AlternatingColorCellRenderer(); jSourcesTable.setDefaultEditor(UnitHolder.class, new UnitCellEditor()); jSourcesTable.setDefaultRenderer(UnitHolder.class, new UnitCellRenderer()); jSourcesTable.setDefaultEditor(Boolean.class, new FakeCellEditor()); jSourcesTable.setDefaultRenderer(Boolean.class, new FakeCellRenderer()); jSourcesTable.setDefaultRenderer(Village.class, new VillageCellRenderer()); jSourcesTable.setDefaultRenderer(String.class, rend); jSourcesTable.setRowHeight(24); jVictimTable.setDefaultRenderer(Tribe.class, new TribeCellRenderer()); jVictimTable.setDefaultRenderer(Village.class, new VillageCellRenderer()); jVictimTable.setDefaultEditor(Boolean.class, new FakeCellEditor()); jVictimTable.setDefaultRenderer(Boolean.class, new FakeCellRenderer()); jVictimTable.setDefaultRenderer(Integer.class, rend); jVictimTable.setDefaultRenderer(String.class, rend); jVictimTable.setRowHeight(24); DefaultComboBoxModel unitModel = new DefaultComboBoxModel( DataHolder.getSingleton().getUnits().toArray(new UnitHolder[] {})); jTroopsList.setModel(unitModel); jTroopsList.setRenderer(new UnitListCellRenderer()); jTroopsList.setSelectedItem(DataHolder.getSingleton().getUnitByPlainName("ram")); jResultFrame.pack(); } catch (Exception e) { logger.error("Failed to initialize TribeAttackFrame", e); } }
From source file:edu.harvard.mcz.imagecapture.VerbatimClassifyDialog.java
/** * This method initializes jComboBoxCollection for entering collections with a controled vocabulary * /*from w w w .j ava 2 s . com*/ * @return javax.swing.JComboBox for collections. */ private JComboBox getJComboBoxCollection() { if (jComboBoxCollection == null) { SpecimenLifeCycle sls = new SpecimenLifeCycle(); jComboBoxCollection = new JComboBox(); jComboBoxCollection.setModel(new DefaultComboBoxModel<String>(sls.getDistinctCollections())); jComboBoxCollection.setEditable(true); jComboBoxCollection.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "Collection")); AutoCompleteDecorator.decorate(jComboBoxCollection); } return jComboBoxCollection; }