commons.java subversion repository

sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Help
HEAD
Rev: 693 - https://secure.bioinfweb.info/Code/svn/commons.java / trunk / main / info.bioinfweb.commons.swing / src / info / bioinfweb / commons / swing / ListBackedComboBoxModel.java
Unified Diff View - ListBackedComboBoxModel.java
/trunk/main/info.bioinfweb.commons.swing/src/info/bioinfweb/commons/swing/ListBackedComboBoxModel.java @ revision 692
/trunk/main/info.bioinfweb.commons.swing/src/info/bioinfweb/commons/swing/ListBackedComboBoxModel.java @ revision 693
@@ -21,10 +21,28 @@ import java.util.List; +import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JList; +import javax.swing.ListModel; +import javax.swing.event.ListDataListener; +/** + * An implementation of {@link ComboBoxModel} that always reflects the contents of a {@link List}. + * <p> + * Note that this model does reflect changes in the underlying list that occur after the creation of this object but will not inform its + * listeners on these. (The underlying list cannot be monitored.) The methods {@link #add(Object)}, {@link #add(int, Object)}, + * {@link #set(int, Object)}, {@link #remove(int)} and {@link #clear()} allow to edit the underlying list and notify all listeners + * registered to this model and the same time. It is recommended to use these methods instead of modifying the list directly if changes + * should be made to a list that is currently displayed in the GUI, e.g., in an instance of {@link JList}. + * + * @author Ben St&ouml;ver + * + * @param <E> the element type of the underlying list and this model + */ public class ListBackedComboBoxModel<E> extends ListBackedListModel<E> implements ComboBoxModel<E> {  private Object selectedItem; @@ -40,6 +58,16 @@  } + /** +  * Sets the selected item of this model. +  * <p> +  * Selected items do not necessarily have to be part of the underlying list. +  * <p> +  * When this method is called a the event {@link ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)} is fired with the +  * start and end indices {@code -1}. (This behaviour is identical with {@link DefaultComboBoxModel}). +  * +  * @param selectedItem the item to be selected from now on +  */  @Override  public void setSelectedItem(Object selectedItem) {   this.selectedItem = selectedItem;


feed icon

sventon 2.5.1

bioinfweb RSS feed bioinfweb on twitter bioinfweb.commons.java on GitHub
bioinfweb - Biology & Informatics Website