/** * Searches an element by its data value. This method is called by the * setSelectedItem method and returns the first occurence of the element. * * @param anItem the item * @return the index of the item or -1 if not found. */ private int findDataElementIndex(final Object anItem) { if (anItem == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) data.get(i); if (anItem.equals(datacon.getKey())) { return i; } } return -1; }
/** * Tries to find the index of element with the given key. The key must not * be null. * * @param key the key for the element to be searched. * @return the index of the key, or -1 if not found. */ public int findElementIndex(final Object key) { if (key == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) data.get(i); if (key.equals(datacon.getValue())) { return i; } } return -1; }
/** * Tries to find the index of element with the given key. The key must not * be null. * * @param key the key for the element to be searched. * @return the index of the key, or -1 if not found. */ public int findElementIndex(final Object key) { if (key == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < this.data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(i); if (key.equals(datacon.getValue())) { return i; } } return -1; }
/** * Returns the key from the given index. * * @param index the index of the key. * @return the the key at the specified index. */ public Object getKeyAt(final int index) { if (index >= this.data.size()) { return null; } if (index < 0) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(index); if (datacon == null) { return null; } return datacon.getKey(); }
/** * Returns the key from the given index. * * @param index the index of the key. * @return the the key at the specified index. */ public Object getKeyAt(final int index) { if (index >= data.size()) { return null; } if (index < 0) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) data.get(index); if (datacon == null) { return null; } return datacon.getKey(); }
/** * Searches an element by its data value. This method is called by the * setSelectedItem method and returns the first occurence of the element. * * @param anItem the item * @return the index of the item or -1 if not found. */ private int findDataElementIndex(final Object anItem) { if (anItem == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < this.data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(i); if (anItem.equals(datacon.getKey())) { return i; } } return -1; }
/** * Searches an element by its data value. This method is called by the * setSelectedItem method and returns the first occurence of the element. * * @param anItem the item * @return the index of the item or -1 if not found. */ private int findDataElementIndex(final Object anItem) { if (anItem == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < this.data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(i); if (anItem.equals(datacon.getKey())) { return i; } } return -1; }
/** * Returns the value at the specified index. * * @param index the requested index * @return the value at <code>index</code> */ public Object getElementAt(final int index) { if (index >= data.size()) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) data.get(index); if (datacon == null) { return null; } return datacon.getValue(); }
/** * Returns the key from the given index. * * @param index the index of the key. * @return the the key at the specified index. */ public Object getKeyAt(final int index) { if (index >= this.data.size()) { return null; } if (index < 0) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(index); if (datacon == null) { return null; } return datacon.getKey(); }
/** * Returns the value at the specified index. * * @param index the requested index * @return the value at <code>index</code> */ public Object getElementAt(final int index) { if (index >= this.data.size()) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(index); if (datacon == null) { return null; } return datacon.getValue(); }
/** * Returns the value at the specified index. * * @param index the requested index * @return the value at <code>index</code> */ public Object getElementAt(final int index) { if (index >= this.data.size()) { return null; } final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(index); if (datacon == null) { return null; } return datacon.getValue(); }
/** * Tries to find the index of element with the given key. The key must not * be null. * * @param key the key for the element to be searched. * @return the index of the key, or -1 if not found. */ public int findElementIndex(final Object key) { if (key == null) { throw new NullPointerException("Item to find must not be null"); } for (int i = 0; i < this.data.size(); i++) { final ComboBoxItemPair datacon = (ComboBoxItemPair) this.data.get(i); if (key.equals(datacon.getValue())) { return i; } } return -1; }
/** * Adds a new entry to the model. * * @param key the key * @param cbitem the display value. */ public void add(final Object key, final Object cbitem) { final ComboBoxItemPair con = new ComboBoxItemPair(key, cbitem); data.add(con); final ListDataEvent evt = new ListDataEvent (this, ListDataEvent.INTERVAL_ADDED, data.size() - 2, data.size() - 2); fireListDataEvent(evt); }
/** * Adds a new entry to the model. * * @param key the key * @param cbitem the display value. */ public void add(final Object key, final Object cbitem) { final ComboBoxItemPair con = new ComboBoxItemPair(key, cbitem); this.data.add(con); final ListDataEvent evt = new ListDataEvent (this, ListDataEvent.INTERVAL_ADDED, this.data.size() - 2, this.data.size() - 2); fireListDataEvent(evt); }
/** * Adds a new entry to the model. * * @param key the key * @param cbitem the display value. */ public void add(final Object key, final Object cbitem) { final ComboBoxItemPair con = new ComboBoxItemPair(key, cbitem); this.data.add(con); final ListDataEvent evt = new ListDataEvent (this, ListDataEvent.INTERVAL_ADDED, this.data.size() - 2, this.data.size() - 2); fireListDataEvent(evt); }