List of usage examples for javax.swing DefaultListModel addElement
public void addElement(E element)
From source file:iaws_desktop.VelibDispoDialogFrame.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed DefaultListModel<VelibStation> listResultat = new DefaultListModel(); if (textStation.getText().equals("")) { listVelib.setModel(listModel);//from w w w . jav a 2 s.c o m } else { for (int i = 0; i < listModel.size(); i++) { if (listModel.getElementAt(i).getName().contains(textStation.getText())) { listResultat.addElement(listModel.getElementAt(i)); } } listVelib.setModel(listResultat); } }
From source file:QuestionGUI.java
public void loadQuestion(Question q) { DefaultListModel<String> dlm = new DefaultListModel<>(); for (String choices : q.getChoices()) { dlm.addElement(choices); }//from w w w .ja v a2 s .c o m questionSelect.setModel(dlm); questionText.setText(q.getQuestion()); questionSelect.setSelectedIndex(0); }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
/** * Set the files to display./*from w ww. jav a2 s.co m*/ * @param files the files */ public void setJarFiles(final String[] files) { boolean doUpdate = false; if (m_filesCache == null) { m_filesCache = files; doUpdate = true; } else { if (!Arrays.deepEquals(m_filesCache, files)) { m_filesCache = files; doUpdate = true; } } if (doUpdate) { DefaultListModel<String> jarListModel = (DefaultListModel<String>) m_addJarList.getModel(); jarListModel.removeAllElements(); for (String f : files) { try { JavaSnippetUtil.toFile(f); // validate existence etc. jarListModel.addElement(f); } catch (InvalidSettingsException e) { // ignore } } } }
From source file:net.sf.jabref.openoffice.AutoDetectPaths.java
private boolean autoDetectPaths() { if (OS.WINDOWS) { List<File> progFiles = findProgramFilesDir(); File sOffice = null;/*from www .j av a 2s . c o m*/ List<File> sofficeFiles = new ArrayList<>(); for (File dir : progFiles) { if (fileSearchCancelled) { return false; } sOffice = findFileDir(dir, "soffice.exe"); if (sOffice != null) { sofficeFiles.add(sOffice); } } if (sOffice == null) { JOptionPane.showMessageDialog(parent, Localization.lang( "Unable to autodetect OpenOffice/LibreOffice installation. Please choose the installation directory manually."), Localization.lang("Could not find OpenOffice/LibreOffice installation"), JOptionPane.INFORMATION_MESSAGE); JFileChooser jfc = new JFileChooser(new File("C:\\")); jfc.setDialogType(JFileChooser.OPEN_DIALOG); jfc.setFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File file) { return file.isDirectory(); } @Override public String getDescription() { return Localization.lang("Directories"); } }); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.showOpenDialog(parent); if (jfc.getSelectedFile() != null) { sOffice = jfc.getSelectedFile(); } } if (sOffice == null) { return false; } if (sofficeFiles.size() > 1) { // More than one file found DefaultListModel<File> mod = new DefaultListModel<>(); for (File tmpfile : sofficeFiles) { mod.addElement(tmpfile); } JList<File> fileList = new JList<>(mod); fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fileList.setSelectedIndex(0); FormBuilder b = FormBuilder.create() .layout(new FormLayout("left:pref", "pref, 2dlu, pref, 4dlu, pref")); b.add(Localization.lang("Found more than one OpenOffice/LibreOffice executable.")).xy(1, 1); b.add(Localization.lang("Please choose which one to connect to:")).xy(1, 3); b.add(fileList).xy(1, 5); int answer = JOptionPane.showConfirmDialog(null, b.getPanel(), Localization.lang("Choose OpenOffice/LibreOffice executable"), JOptionPane.OK_CANCEL_OPTION); if (answer == JOptionPane.CANCEL_OPTION) { return false; } else { sOffice = fileList.getSelectedValue(); } } else { sOffice = sofficeFiles.get(0); } return setupPreferencesForOO(sOffice.getParentFile(), sOffice, "soffice.exe"); } else if (OS.OS_X) { File rootDir = new File("/Applications"); File[] files = rootDir.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory() && ("OpenOffice.org.app".equals(file.getName()) || "LibreOffice.app".equals(file.getName()))) { rootDir = file; break; } } } File sOffice = findFileDir(rootDir, SOFFICE_BIN); if (fileSearchCancelled) { return false; } if (sOffice == null) { return false; } else { return setupPreferencesForOO(rootDir, sOffice, SOFFICE_BIN); } } else { // Linux: String usrRoot = "/usr/lib"; File inUsr = findFileDir(new File(usrRoot), SOFFICE); if (fileSearchCancelled) { return false; } if (inUsr == null) { inUsr = findFileDir(new File("/usr/lib64"), SOFFICE); if (inUsr != null) { usrRoot = "/usr/lib64"; } } if (fileSearchCancelled) { return false; } File inOpt = findFileDir(new File("/opt"), SOFFICE); if (fileSearchCancelled) { return false; } if ((inUsr != null) && (inOpt == null)) { return setupPreferencesForOO(usrRoot, inUsr, SOFFICE_BIN); } else if (inOpt != null) { if (inUsr == null) { return setupPreferencesForOO("/opt", inOpt, SOFFICE_BIN); } else { // Found both JRadioButton optRB = new JRadioButton(inOpt.getPath(), true); JRadioButton usrRB = new JRadioButton(inUsr.getPath(), false); ButtonGroup bg = new ButtonGroup(); bg.add(optRB); bg.add(usrRB); FormBuilder b = FormBuilder.create() .layout(new FormLayout("left:pref", "pref, 2dlu, pref, 2dlu, pref ")); b.add(Localization.lang( "Found more than one OpenOffice/LibreOffice executable. Please choose which one to connect to:")) .xy(1, 1); b.add(optRB).xy(1, 3); b.add(usrRB).xy(1, 5); int answer = JOptionPane.showConfirmDialog(null, b.getPanel(), Localization.lang("Choose OpenOffice/LibreOffice executable"), JOptionPane.OK_CANCEL_OPTION); if (answer == JOptionPane.CANCEL_OPTION) { return false; } if (optRB.isSelected()) { return setupPreferencesForOO("/opt", inOpt, SOFFICE_BIN); } else { return setupPreferencesForOO(usrRoot, inUsr, SOFFICE_BIN); } } } } return false; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellStatisticsController.java
/** * Update the list with conditions./*from w ww . ja v a2s . c om*/ */ public void updateConditionList() { JList conditionList = singleCellAnalysisController.getAnalysisPanel().getConditionList(); DefaultListModel model = (DefaultListModel) conditionList.getModel(); if (singleCellAnalysisController.isFilteredData()) { singleCellAnalysisController.getFilteringMap().keySet().stream().forEach((conditionDataHolder) -> { model.addElement(conditionDataHolder.getPlateCondition()); }); } else { singleCellAnalysisController.getPreProcessingMap().values().stream().forEach((conditionDataHolder) -> { model.addElement(conditionDataHolder.getPlateCondition()); }); } }
From source file:com.neurotec.samples.panels.EnrollFromScanner.java
public void updateScannerList() { DefaultListModel model = (DefaultListModel) scannerList.getModel(); model.clear();// www . j a v a 2s . c o m for (NDevice device : deviceManager.getDevices()) { model.addElement(device); } NFingerScanner scanner = (NFingerScanner) FingersTools.getInstance().getClient().getFingerScanner(); if ((scanner == null) && (model.getSize() > 0)) { scannerList.setSelectedIndex(0); } else if (scanner != null) { scannerList.setSelectedValue(scanner, true); } }
From source file:Import.pnl_import_vcf.java
private void btn_importActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_importActionPerformed // TODO add your handling code here: String[] singleColumns = singleColumns(); String[] selectedFamilies = selectedFamilies(); CheckBoxList checkList = new CheckBoxList(); DefaultListModel model = new DefaultListModel(); for (String a : singleColumns) { model.addElement(a); }//from w ww. ja va 2 s .c o m checkList.setModel(model); String filePath = filePathField.getText(); if (rbt_existing_tbl.isSelected()) { try { String[] selectedTableFamilies = tableFamilies(); JTable tableMap = new JTable(); DefaultTableModel tableMapModel = (DefaultTableModel) tableMap.getModel(); setMapTable(tableMap, tableMapModel, selectedFamilies, selectedTableFamilies); int map = JOptionPane.showConfirmDialog(null, tableMap, "Please map to column", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (map == 2) { return; } Object[] o = getMapPair(tableMapModel); String selectTableName = tbl_hbase_tables.getValueAt(tbl_hbase_tables.getSelectedRow(), 0) .toString(); String[] mappedFamilies = (String[]) o[1]; String[] mappedTableFamilies = (String[]) o[0]; String[] keys = getKey(selectTableName); importToTable.importDataJob importData = new importDataJob(); importData.importData(filePath, selectTableName, mappedTableFamilies, mappedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } else { try { int key = JOptionPane.showConfirmDialog(null, checkList, "Please choose Key", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (key == 2) { return; } Object[] selectedKey = checkList.getCheckBoxListSelectedValues(); File f = new File(filePath); String fname = f.getName(); String tableName = FilenameUtils.removeExtension(fname); writeKey(selectedKey, tableName); writeType(tableName); createColumnsTxt(tableName); ArrayList<String> list = new ArrayList<>(); for (Object o : selectedKey) { list.add(o.toString()); } String[] keys = list.toArray(new String[list.size()]); importToNewTable.createDataJob importData = new createDataJob(); importData.importData(filePath, selectedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } filePathField.setText(null); DefaultDualListModel dualModel = new DefaultDualListModel(); list_dual_hbase_column_family.setModel(dualModel); pnl_import_vcf.showHBaseTables runabletask = new pnl_import_vcf.showHBaseTables(); new Thread(runabletask).start(); }
From source file:FontChooser.java
private void setListValues(JList list, String[] values) { if (list.getModel() instanceof DefaultListModel) { DefaultListModel model = (DefaultListModel) list.getModel(); model.removeAllElements();//from w ww .j av a 2 s.co m for (String value : values) { model.addElement(value); } } }
From source file:gtu._work.ui.TextScanUI.java
private void resetGroupList(int groupCount) { DefaultListModel model = new DefaultListModel(); for (int ii = 0; ii <= groupCount; ii++) { model.addElement(ii); }/*from w w w . ja v a 2 s.c om*/ groupList.setModel(model); }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java
@Override public void createUI() { super.createUI(); CellConstraints cc = new CellConstraints(); // get formatters for field List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName())); Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() { public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.getName().compareTo(o2.getName()); }/*from www . j a v a2 s . c o m*/ }); // table and field titles PanelBuilder tblInfoPB = new PanelBuilder( new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/); String typeStr = fieldInfo.getType(); typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr; JLabel tableTitleLbl = createLabel(getResourceString("FFE_TABLE") + ":"); JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle()); tableTitleValueLbl.setBackground(Color.WHITE); tableTitleValueLbl.setOpaque(true); JLabel fieldTitleLbl = createLabel(getResourceString("FFE_FIELD") + ":"); JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle()); fieldTitleValueLbl.setBackground(Color.WHITE); fieldTitleValueLbl.setOpaque(true); //JLabel fieldTypeLbl = createLabel(getResourceString("FFE_TYPE") + ":"); //JLabel fieldTypeValueLbl = createLabel(typeStr); //fieldTypeValueLbl.setBackground(Color.WHITE); //fieldTypeValueLbl.setOpaque(true); JLabel fieldLengthLbl = createLabel(getResourceString("FFE_LENGTH") + ":"); JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength())); fieldLengthValueLbl.setBackground(Color.WHITE); fieldLengthValueLbl.setOpaque(true); int y = 1; tblInfoPB.add(tableTitleLbl, cc.xy(1, y)); tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldTitleLbl, cc.xy(1, y)); tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y)); y += 2; //tblInfoPB.add(fieldTypeLbl, cc.xy(1, y)); //tblInfoPB.add(fieldTypeValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldLengthLbl, cc.xy(1, y)); tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y)); y += 2; DefaultListModel listModel = new DefaultListModel(); // add available formatters for (UIFieldFormatterIFace format : fmtrs) { listModel.addElement(format); } formatList = createList(listModel); formatList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //formatList.setCellRenderer(new FmtListRenderer()); hookFormatListSelectionListener(); hookFormatListMouseListener(); ActionListener deleteListener = new ActionListener() { public void actionPerformed(ActionEvent e) { deleteFormatter(); } }; ActionListener editListener = new ActionListener() { public void actionPerformed(ActionEvent e) { editFormatter((UIFieldFormatter) formatList.getSelectedValue(), false); } }; ActionListener addListener = new ActionListener() { public void actionPerformed(ActionEvent e) { addFormatter(); } }; ActionListener defListener = new ActionListener() { public void actionPerformed(ActionEvent e) { setAsDefFormatter(); } }; dedaPanel = new DefEditDeleteAddPanel(defListener, editListener, deleteListener, addListener, "FFE_DEF", "FFE_EDT", "FFE_DEL", "FFE_ADD"); dedaPanel.getAddBtn().setEnabled(true); PanelBuilder pb = new PanelBuilder(new FormLayout("f:max(250px;p):g", "p,4px,p,2px,f:p:g,4px,p")); y = 1; pb.add(tblInfoPB.getPanel(), cc.xy(1, y)); y += 2; pb.add(createI18NLabel("FFE_AVAILABLE_FORMATS", SwingConstants.LEFT), cc.xy(1, y)); y += 2; pb.add(createScrollPane(formatList), cc.xy(1, y)); y += 2; pb.add(dedaPanel, cc.xy(1, y)); y += 2; pb.setDefaultDialogBorder(); //pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); okBtn.setEnabled(false); pack(); }