List of usage examples for javax.swing DefaultComboBoxModel addElement
public void addElement(E anObject)
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanel.java
/** * @param altView/* ww w . j a va 2 s.co m*/ */ protected void setDataIntoUI(final AltView altView) { ValComboBox cbx = (ValComboBox) formViewObj.getControlByName("defaultMode"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) cbx.getModel(); model.removeAllElements(); int cnt = 0; int inx = 0; for (AltViewIFace.CreationMode mode : AltViewIFace.CreationMode.values()) { model.addElement(mode); if (mode == altView.getMode()) { inx = cnt; } cnt++; } cbx.getComboBox().setSelectedIndex(inx); }
From source file:com.declarativa.interprolog.gui.Ini.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {/*from ww w . ja v a 2s . c o m*/ Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); //********************** DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); /* final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>(shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox.getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); */ final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); jLayeredPane1.setSize(456, 458); //// jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); /* int returnVal = fileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); fileChooser.addChoosableFileFilter(new FileFilter() { public String getDescription() { return "Prolog native program (*.P)"; } public boolean accept(File f) { if (f.isDirectory()) { return true; } else { return f.getName().toLowerCase().endsWith(".P"); } } }); try { // What to do with the file, e.g. display it in a TextArea prologOutput.read(new FileReader(file.getAbsolutePath()), null); } catch (IOException ex) { System.out.println("problem accessing file" + file.getAbsolutePath()); } } else { System.out.println("File access cancelled by user."); } */ //One file chooser for each buton click } catch (IOException ex) { Exceptions.printStackTrace(ex); System.out.println("AUCH"); } }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanel.java
/** * @param fc//ww w . ja v a2 s .co m * @param rows * @param rowInx * @param cols * @param colInx * @param enableNaming */ protected void setDataIntoBase(final FormCell fc, final int rows, final int rowDefs, final int rowInx, final int cols, final int colDefs, final int colInx, final boolean enableNaming) { if (formViewObj == null) { return; } int inx; int cnt; String fName = fc.getName(); ValComboBox nameCBX = (ValComboBox) formViewObj.getControlByName("namecbx"); //$NON-NLS-1$ if (StringUtils.isNotEmpty(fName) || enableNaming) { DefaultComboBoxModel model = (DefaultComboBoxModel) nameCBX.getModel(); inx = -1; cnt = 0; for (DBFieldInfo fi : tableInfo.getFields()) { model.addElement(fi.getTitle()); //System.out.println("["+fi.getName()+"]["+fName+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (fi.getTitle().equals(fName) || fi.getName().equals(fName)) { inx = cnt; } cnt++; } for (DBRelationshipInfo ri : tableInfo.getRelationships()) { if (ri.getType() == DBRelationshipInfo.RelationshipType.ManyToOne) { model.addElement(ri.getTitle()); if (inx == -1) { //System.out.println("*["+ri.getTitle()+"]["+fName+"]"); if (ri.getTitle().equals(fName) || ri.getName().equals(fName)) { inx = cnt; } } cnt++; } } nameCBX.getComboBox().setSelectedIndex(inx); nameCBX.setEnabled(true); } else { nameCBX.setEnabled(false); } if (true) { int rowDefsLeft = rowDefs - rows; ValComboBox rowSpanCBX = (ValComboBox) formViewObj.getControlByName("rowspancbx"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) rowSpanCBX.getModel(); if (rowDefsLeft == 0) { model.addElement("1"); //$NON-NLS-1$ inx = 0; rowSpanCBX.setEnabled(false); } else { inx = 0; cnt = 0; for (int i = 1; i <= rowDefsLeft; i++) { model.addElement(Integer.toString(i)); if (i == fc.getRowspan()) { inx = cnt; } } rowSpanCBX.setEnabled(rowDefsLeft > 1); rowSpanCBX.getComboBox().setSelectedIndex(inx); } ValComboBox colSpanCBX = (ValComboBox) formViewObj.getControlByName("colspancbx"); //$NON-NLS-1$ model = (DefaultComboBoxModel) colSpanCBX.getModel(); int colDefsLeft = colDefs - cols; if (colDefsLeft == 0) { model.addElement("1"); //$NON-NLS-1$ inx = 1; colSpanCBX.setEnabled(false); } else { inx = 0; cnt = 0; for (int i = 1; i <= colDefsLeft; i++) { model.addElement(Integer.toString(i)); if (i == fc.getColspan()) { inx = cnt; } } colSpanCBX.setEnabled(colDefsLeft > 1); colSpanCBX.getComboBox().setSelectedIndex(inx); } } ValCheckBox chkbx = (ValCheckBox) formViewObj.getControlByName("ignoreSetGet"); //$NON-NLS-1$ chkbx.setSelected(fc.isIgnoreSetGet()); chkbx = (ValCheckBox) formViewObj.getControlByName("changeListenerOnly"); //$NON-NLS-1$ chkbx.setSelected(fc.isChangeListenerOnly()); }
From source file:au.org.ala.delta.intkey.ui.TaxonInformationDialog.java
private void initialize() { // fill combobox with taxa names DefaultComboBoxModel comboModel = new DefaultComboBoxModel(); for (Item taxon : _taxa) { String formattedItemName = _itemFormatter.formatItemDescription(taxon); formattedItemName = formattedItemName.replace("<", ""); formattedItemName = formattedItemName.replace(">", ""); comboModel.addElement(formattedItemName); }//from w w w . j av a 2s . c om _comboBox.setModel(comboModel); displayTaxon(0); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelOld.java
/** * @param fcf/*from w w w. j a va2s .com*/ * @param rows * @param rowInx * @param cols * @param colInx */ public void setDataIntoUI(final FormCellField fcf, final int rows, final int rowDefs, final int rowInx, final int cols, final int colDefs, final int colInx) { if (formViewObj == null) { return; } currentData = fcf; //viewPanel.getMultiView().setData(fcf); int inx; int cnt; setDataIntoBase(fcf, rows, rowDefs, rowInx, cols, colDefs, colInx, true); setDataIntoBase(fcf); JTextField typeLabel = (JTextField) formViewObj.getControlByName("type"); //$NON-NLS-1$ typeLabel.setText(fcf.getUiType().toString()); /* ValComboBox typeCBX = (ValComboBox)formViewObj.getControlByName("typecbx"); DefaultComboBoxModel model = (DefaultComboBoxModel)typeCBX.getModel(); inx = -1; cnt = 0; for (String type : subcontrolHash.keySet()) { model.addElement(type); if (type.equals(fcf.getUiType().toString())) { inx = cnt; } cnt++; } typeCBX.getComboBox().setSelectedIndex(inx);*/ if (fcf.getUiType() == FormCellFieldIFace.FieldType.combobox) { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); List<?> pickLists = session.getDataList(PickList.class); ValComboBox pickListCBX = (ValComboBox) formViewObj.getControlByName("picklistcbx"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) pickListCBX.getModel(); inx = 0; cnt = 1; String dataPickListName = fcf.getPickListName(); pickList.clear(); model.addElement(getResourceString("EditorPropPanelOld.NONE"));//$NON-NLS-1$ for (Iterator<?> iter = pickLists.iterator(); iter.hasNext();) { PickList pl = (PickList) iter.next(); String name = pl.getName(); pickList.put(pl.getName(), pl.getIdentityTitle()); model.addElement(name); if (StringUtils.isNotEmpty(dataPickListName) && dataPickListName.equals(name)) { inx = cnt; } cnt++; } session.close(); pickListCBX.getComboBox().setSelectedIndex(inx); ValTextArea textArea = (ValTextArea) formViewObj.getControlByName("list"); //$NON-NLS-1$ String list = fcf.getProperty("list"); //$NON-NLS-1$ if (list != null) { textArea.setText(list); } } viewDefMultiView.validateAll(); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanel.java
/** * @param fcf//w ww .j av a2 s . c o m * @param rows * @param rowInx * @param cols * @param colInx */ public void setDataIntoUI(final FormViewDef fvd, final FormCellField fcf, final int rows, final int rowDefs, final int rowInx, final int cols, final int colDefs, final int colInx) { if (formViewObj == null) { return; } formViewDef = fvd; currentFC = fcf; data = fcf; //viewPanel.getMultiView().setData(fcf); int inx; int cnt; setDataIntoBase(fcf, rows, rowDefs, rowInx, cols, colDefs, colInx, true); setDataIntoBase(fcf); JTextField typeLabel = (JTextField) formViewObj.getControlByName("type"); //$NON-NLS-1$ typeLabel.setText(fcf.getUiType().toString()); /* ValComboBox typeCBX = (ValComboBox)formViewObj.getControlByName("typecbx"); DefaultComboBoxModel model = (DefaultComboBoxModel)typeCBX.getModel(); inx = -1; cnt = 0; for (String type : subcontrolHash.keySet()) { model.addElement(type); if (type.equals(fcf.getUiType().toString())) { inx = cnt; } cnt++; } typeCBX.getComboBox().setSelectedIndex(inx);*/ if (fcf.getUiType() == FormCellFieldIFace.FieldType.combobox) { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); List<?> pickLists = session.getDataList(PickList.class); ValComboBox pickListCBX = (ValComboBox) formViewObj.getControlByName("picklistcbx"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) pickListCBX.getModel(); inx = 0; cnt = 1; String dataPickListName = fcf.getPickListName(); pickList.clear(); model.addElement(getResourceString("EditorPropPanel.NONE")); //$NON-NLS-1$ for (Iterator<?> iter = pickLists.iterator(); iter.hasNext();) { PickList pl = (PickList) iter.next(); String name = pl.getName(); pickList.put(pl.getName(), pl.getIdentityTitle()); model.addElement(name); if (StringUtils.isNotEmpty(dataPickListName) && dataPickListName.equals(name)) { inx = cnt; } cnt++; } session.close(); pickListCBX.getComboBox().setSelectedIndex(inx); ValTextArea textArea = (ValTextArea) formViewObj.getControlByName("list"); //$NON-NLS-1$ String list = fcf.getProperty("list"); //$NON-NLS-1$ if (list != null) { textArea.setText(list); } } multiView.validateAll(); }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
protected void updateDisplayCombo() { // save selected aggregator because that one will be reset when elements are removed from combo box model DataObjAggregator tempAgg = selectedAggregator; // clear combo box list DefaultComboBoxModel cboModel = (DefaultComboBoxModel) displayCbo.getModel(); cboModel.removeAllElements();// w w w . ja v a 2s. c o m // add formatters to display combo box List<DataObjSwitchFormatter> fmts = dataObjFieldFormatMgrCache.getFormatterList(tableInfo.getClassObj()); // add an empty entry at the beginning so the user can clear the selection if he wants to cboModel.addElement(getResourceString("NONE")); if (fmts.size() == 0) { return; } int selectedFieldIndex = 0; for (int i = 0; i < fmts.size(); ++i) { DataObjSwitchFormatter currentFormat = fmts.get(i); cboModel.addElement(currentFormat); if (tempAgg != null && currentFormat.getName().equals(tempAgg.getFormatName())) { // found the selected field // current combo index is (i+1) because of empty entry at the beginning selectedFieldIndex = i + 1; } } // set selected field displayCbo.setSelectedIndex(selectedFieldIndex); }
From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java
public void updateStructure() { DefaultComboBoxModel dcb_model = new DefaultComboBoxModel(); String firstRole = ""; // Roles//from w w w .j a va 2 s . c om dcb_model = new DefaultComboBoxModel(); synchronized (lock) { @SuppressWarnings("rawtypes") Iterator iter = model.getRootElement().getChild("RoleSetup").getChildren().iterator(); while (iter.hasNext()) { Element er = (Element) iter.next(); int roleId = DomTools.getAttributeInt(er, "id", 0, false); if (roleId > 0) { SlimRoleItem item = new SlimRoleItem(er); if (firstRole.length() == 0) { firstRole = item.toString(); } dcb_model.addElement(item); } } } phoneOnlyContentPane.setRole(firstRole); //contentPane.getRoleJLabel().setModel(dcb_model); // Peers updatePeerStructure(); // Update and repaint updateIndicators(); ((JPanel) phoneOnlyContentPane).revalidate(); ((JPanel) phoneOnlyContentPane).repaint(); }
From source file:io.github.jeddict.jpa.modeler.properties.named.nativequery.NamedNativeQueryPanel.java
private void addResultClass(String resultClass) { DefaultComboBoxModel model = (DefaultComboBoxModel) resultClass_jComboBox.getModel(); String unqualifiedClassName = getClassName(resultClass); if (model.getIndexOf(unqualifiedClassName) != -1) { // check if it is Entity then select resultClass_jComboBox.setSelectedItem(unqualifiedClassName); } else { //if other class if (model.getIndexOf(resultClass) == -1) { model.addElement(resultClass); }/*from w ww . j a va 2 s .com*/ resultClass_jComboBox.setSelectedItem(resultClass); } }
From source file:at.nhmwien.schema_mapping_tool.ProcessMappingWindow.java
/** Creates new form ProcessMappingWindow */ public ProcessMappingWindow() { initComponents();/*from www. j a v a2s . c o m*/ // Disable the abort button by default this.abortButton.setEnabled(false); // Add the available file types to the dropdown String[] fpTypes = ProcessorHandler.self().getProcessors(); DefaultComboBoxModel iffCbModel = new DefaultComboBoxModel(); DefaultComboBoxModel offCbModel = new DefaultComboBoxModel(); for (int i = 0; i < fpTypes.length; i++) { iffCbModel.addElement(fpTypes[i]); offCbModel.addElement(fpTypes[i]); // Get all valid file-types for this handler and add a filenameextensionfilter for it /*String[] fpFileTypes = ProcessorHandler.self().getSupportedFilesForType(fpTypes[i]); if( fpFileTypes != null ) { String fpFTDescription = fpTypes[i] + " (*." + fpFileTypes[0]; for( int j = 1; j < fpFileTypes.length; j++ ) { fpFTDescription += ", *." + fpFileTypes[j]; } fpFTDescription += ")"; //FileNameExtensionFilter filter = new FileNameExtensionFilter( fpFTDescription, fpFileTypes ); //fc.addChoosableFileFilter(filter); }*/ } this.inputFileFormatComboBox.setModel(iffCbModel); this.outputFileFormatComboBox.setModel(offCbModel); // Add all available character encodings to the drop-down DefaultComboBoxModel ifECbModel = new DefaultComboBoxModel(); DefaultComboBoxModel ofECbModel = new DefaultComboBoxModel(); SortedMap<String, Charset> availChars = Charset.availableCharsets(); Iterator<Map.Entry<String, Charset>> acIt = availChars.entrySet().iterator(); while (acIt.hasNext()) { Map.Entry<String, Charset> currEntry = acIt.next(); ifECbModel.addElement(currEntry.getValue()); ofECbModel.addElement(currEntry.getValue()); } this.ifEncodingComboBox.setModel(ifECbModel); this.ofEncodingComboBox.setModel(ofECbModel); this.mp = new MappingProcess(); // Create our initial settings windows inputFileFormatComboBoxActionPerformed(null); outputFileFormatComboBoxActionPerformed(null); }