@SuppressWarnings("unchecked") public void addSource(File file, boolean resolve) { // TODO: put in some whitelist / blacklist parameters if (resolve && file.isDirectory()) { // resolve the /src/main/java portion of source directories. File next = new File(file, "src"); if (next.exists()) { file = next; next = new File(file, "main"); if (next.exists()) { file = next; next = new File(file, "java"); if (next.exists()) { file = next; } } } } if (file.isDirectory() || file.toString().endsWith(".jar")) { int was = dir.indexOf(file); if (was > -1) { dir.remove(was); } dir.add(dir.getSize(), file); } }
public void addElement(Object o) { Comparable a = (Comparable) o; int i = 0; for (i = 0; i < getSize(); i++) { if (a.compareTo(getElementAt(i)) < 0) { break; } } super.add(i, o); }
public void buildNorth() { title.setFont(titleFont); list.add(0, "Select Planet"); list.add(1, "Mercury"); list.add(2, "Venus"); list.add(3, "Earth"); list.add(4, "Mars"); list.add(5, "Asteroids"); list.add(6, "Jupiter"); list.add(7, "Saturn"); list.add(8, "Uranus"); list.add(9, "Neptune"); list.add(10, "Pluto"); ImageIcon fig = new ImageIcon(getImage(getCodeBase(), "Images/ss.jpg")); display = new JLabel(fig); factChoice.addItem("Select Fact"); factChoice.addItem("Volume"); factChoice.addItem("Surface Area"); factChoice.addItem("Density"); factChoice.addItem("Temperature"); factChoice.addItem("Distance From Earth"); factChoice.addItem("Diameter"); pNorth1.setOpaque(false); pNorth2.setOpaque(false); pNorth3.setOpaque(false); pNorth4.setOpaque(false); pNorth5.setOpaque(false); moons.setOpaque(false); whatUnits.setOpaque(false); add("North", pNorth1); pNorth1.add(pNorth2); pNorth2.add(planets); pNorth1.add(display); pNorth1.add(pNorth3); pNorth3.add("North", factChoice); pNorth3.add("Center", pNorth4); pNorth4.add(moons); pNorth4.add(whatUnits); pNorth3.add("South", pNorth5); pNorth5.add(fact); pNorth5.add(units); pNorth5.add(select); pNorth5.add(clear); }
public void addTileButton() { DefaultListModel lm = (DefaultListModel) gui.tileList.getModel(); if (gui.tileList.getSelectedIndex() == -1) { tiles.add(ctx.players.local().tile()); lm.addElement(ctx.players.local().tile().x() + ", " + ctx.players.local().tile().y()); } else { tiles.add(gui.tileList.getSelectedIndex() + 1, ctx.players.local().tile()); lm.add( gui.tileList.getSelectedIndex() + 1, ctx.players.local().tile().x() + ", " + ctx.players.local().tile().y()); } gui.tileList.setModel(lm); }
private void updateList() { list.removeAll(); DefaultListModel model = new DefaultListModel(); if (shapefile == null) { return; } if (new File(shapefile.replace(".shp", ".dbf")).exists()) { try { AttributeTable table = new AttributeTable(shapefile.replace(".shp", ".dbf")); DBFField[] fields = table.getAllFields(); for (DBFField field : fields) { model.add(model.size(), field.getName()); } } catch (Exception e) { } } else { model.add(0, ""); } list.setModel(model); }
/** * Adds a new <tt>ConfigurationForm</tt> to this list. * * @param configForm The <tt>ConfigurationForm</tt> to add. */ public void addConfigForm(ConfigurationForm configForm) { if (configForm == null) throw new IllegalArgumentException("configForm"); DefaultListModel listModel = (DefaultListModel) configList.getModel(); int i = 0; int count = listModel.getSize(); int configFormIndex = configForm.getIndex(); for (; i < count; i++) { ConfigurationForm form = (ConfigurationForm) listModel.get(i); if (configFormIndex < form.getIndex()) break; } listModel.add(i, configForm); }
public void setMap( HashMap map, JTextArea textArea, JTextField[] textFields, JLabel[] labels, JLabel actionLabel) { this.map = map; this.textArea = textArea; this.textFields = textFields; this.labels = labels; this.table = table; this.action = actionLabel; int index = 0; for (Object o : map.keySet().toArray()) { listModel.add(index, o.toString()); index++; } }
private void setupWordSelector() { // Have we already created a listmodel for this field? wordListModel = wordListModels.get(currentField); if (wordListModel != null) { wordList.setModel(wordListModel); } else { wordListModel = new DefaultListModel(); wordList.setModel(wordListModel); wordListModels.put(currentField, wordListModel); // wordListModel.addElement(WORD_FIRSTLINE_TEXT); Vector<String> items = metaData.getData(Globals.SELECTOR_META_PREFIX + currentField); if (items != null) { wordSet = new TreeSet<String>(items); int index = 0; for (String s : wordSet) { wordListModel.add(index, s); index++; } } } }
public boolean importData(JComponent c, Transferable t) { if (sourceIndices == null || !canImport(c, t.getTransferDataFlavors())) { return false; } JList target = null; ArrayList alist = null; try { target = (JList) c; if (hasLocalArrayListFlavor(t.getTransferDataFlavors())) { alist = (ArrayList) t.getTransferData(localArrayListFlavor); } else if (hasSerialArrayListFlavor(t.getTransferDataFlavors())) { alist = (ArrayList) t.getTransferData(serialArrayListFlavor); } else { return false; } } catch (UnsupportedFlavorException ufe) { System.out.println("importData: unsupported data flavor"); return false; } catch (IOException ioe) { System.out.println("importData: I/O exception"); return false; } //At this point we use the same code to retrieve the data //locally or serially. //We'll drop at the current selected index. int targetIndex = target.getSelectedIndex(); //Prevent the user from dropping data back on itself. //For example, if the user is moving items #4,#5,#6 and #7 and //attempts to insert the items after item #5, this would //be problematic when removing the original items. //This is interpreted as dropping the same data on itself //and has no effect. if (source.equals(target)) { //System.out.print("checking indices index TO: " + targetIndex + " FROM:"); //for (int i = 0; i < sourceIndices.length;i++) //System.out.print(" "+sourceIndices[i]); //System.out.println(""); if (targetIndex >= sourceIndices[0] && targetIndex <= sourceIndices[sourceIndices.length - 1]) { //System.out.println("setting indices null : " + targetIndex + " " + sourceIndices[0] + " " + sourceIndices[sourceIndices.length - 1]); sourceIndices = null; return true; } } DefaultListModel listModel = (DefaultListModel) target.getModel(); int max = listModel.getSize(); if (targetIndex < 0) { targetIndex = max; } else { if (sourceIndices[0] < targetIndex) targetIndex++; if (targetIndex > max) { targetIndex = max; } } addIndex = targetIndex; addCount = alist.size(); for (int i = 0; i < alist.size(); i++) { listModel.add(targetIndex++, objectOf(listModel, alist.get(i))); } return true; }
private void newWordAction() { if ((wordListModel.size() == 0) || !wordListModel.get(0).equals(WORD_FIRSTLINE_TEXT)) wordListModel.add(0, WORD_FIRSTLINE_TEXT); wordList.setSelectedIndex(0); wPane.getVerticalScrollBar().setValue(0); }