< prev index next >

src/java.desktop/share/classes/javax/swing/text/html/OptionListModel.java

Print this page




  82         }
  83     }
  84 
  85     public boolean isSelectedIndex(int index) {
  86         return ((index < minIndex) || (index > maxIndex)) ? false : value.get(index);
  87     }
  88 
  89     public boolean isSelectionEmpty() {
  90         return (minIndex > maxIndex);
  91     }
  92 
  93     public void addListSelectionListener(ListSelectionListener l) {
  94         listenerList.add(ListSelectionListener.class, l);
  95     }
  96 
  97     public void removeListSelectionListener(ListSelectionListener l) {
  98         listenerList.remove(ListSelectionListener.class, l);
  99     }
 100 
 101     /**
 102      * Returns an array of all the <code>ListSelectionListener</code>s added
 103      * to this OptionListModel with addListSelectionListener().
 104      *
 105      * @return all of the <code>ListSelectionListener</code>s added or an empty
 106      *         array if no listeners have been added
 107      * @since 1.4
 108      */
 109     public ListSelectionListener[] getListSelectionListeners() {
 110         return listenerList.getListeners(ListSelectionListener.class);
 111     }
 112 
 113     /**
 114      * Notify listeners that we are beginning or ending a
 115      * series of value changes
 116      */
 117     protected void fireValueChanged(boolean isAdjusting) {
 118         fireValueChanged(getMinSelectionIndex(), getMaxSelectionIndex(), isAdjusting);
 119     }
 120 
 121 
 122     /**
 123      * Notify ListSelectionListeners that the value of the selection,
 124      * in the closed interval firstIndex,lastIndex, has changed.
 125      */


 444             setState(i, value.get(i + gapLength));
 445         }
 446     }
 447 
 448 
 449     public void setValueIsAdjusting(boolean isAdjusting) {
 450         if (isAdjusting != this.isAdjusting) {
 451             this.isAdjusting = isAdjusting;
 452             this.fireValueChanged(isAdjusting);
 453         }
 454     }
 455 
 456 
 457     public String toString() {
 458         String s =  ((getValueIsAdjusting()) ? "~" : "=") + value.toString();
 459         return getClass().getName() + " " + Integer.toString(hashCode()) + " " + s;
 460     }
 461 
 462     /**
 463      * Returns a clone of the receiver with the same selection.
 464      * <code>listenerLists</code> are not duplicated.
 465      *
 466      * @return a clone of the receiver
 467      * @exception CloneNotSupportedException if the receiver does not
 468      *    both (a) implement the <code>Cloneable</code> interface
 469      *    and (b) define a <code>clone</code> method
 470      */
 471     public Object clone() throws CloneNotSupportedException {
 472         @SuppressWarnings("unchecked")
 473         OptionListModel<E> clone = (OptionListModel)super.clone();
 474         clone.value = (BitSet)value.clone();
 475         clone.listenerList = new EventListenerList();
 476         return clone;
 477     }
 478 
 479     public int getAnchorSelectionIndex() {
 480         return anchorIndex;
 481     }
 482 
 483     public int getLeadSelectionIndex() {
 484         return leadIndex;
 485     }
 486 
 487     /**
 488      * Set the anchor selection index, leaving all selection values unchanged.
 489      *




  82         }
  83     }
  84 
  85     public boolean isSelectedIndex(int index) {
  86         return ((index < minIndex) || (index > maxIndex)) ? false : value.get(index);
  87     }
  88 
  89     public boolean isSelectionEmpty() {
  90         return (minIndex > maxIndex);
  91     }
  92 
  93     public void addListSelectionListener(ListSelectionListener l) {
  94         listenerList.add(ListSelectionListener.class, l);
  95     }
  96 
  97     public void removeListSelectionListener(ListSelectionListener l) {
  98         listenerList.remove(ListSelectionListener.class, l);
  99     }
 100 
 101     /**
 102      * Returns an array of all the {@code ListSelectionListener}s added
 103      * to this OptionListModel with addListSelectionListener().
 104      *
 105      * @return all of the {@code ListSelectionListener}s added or an empty
 106      *         array if no listeners have been added
 107      * @since 1.4
 108      */
 109     public ListSelectionListener[] getListSelectionListeners() {
 110         return listenerList.getListeners(ListSelectionListener.class);
 111     }
 112 
 113     /**
 114      * Notify listeners that we are beginning or ending a
 115      * series of value changes
 116      */
 117     protected void fireValueChanged(boolean isAdjusting) {
 118         fireValueChanged(getMinSelectionIndex(), getMaxSelectionIndex(), isAdjusting);
 119     }
 120 
 121 
 122     /**
 123      * Notify ListSelectionListeners that the value of the selection,
 124      * in the closed interval firstIndex,lastIndex, has changed.
 125      */


 444             setState(i, value.get(i + gapLength));
 445         }
 446     }
 447 
 448 
 449     public void setValueIsAdjusting(boolean isAdjusting) {
 450         if (isAdjusting != this.isAdjusting) {
 451             this.isAdjusting = isAdjusting;
 452             this.fireValueChanged(isAdjusting);
 453         }
 454     }
 455 
 456 
 457     public String toString() {
 458         String s =  ((getValueIsAdjusting()) ? "~" : "=") + value.toString();
 459         return getClass().getName() + " " + Integer.toString(hashCode()) + " " + s;
 460     }
 461 
 462     /**
 463      * Returns a clone of the receiver with the same selection.
 464      * {@code listenerLists} are not duplicated.
 465      *
 466      * @return a clone of the receiver
 467      * @exception CloneNotSupportedException if the receiver does not
 468      *    both (a) implement the {@code Cloneable} interface
 469      *    and (b) define a {@code clone} method
 470      */
 471     public Object clone() throws CloneNotSupportedException {
 472         @SuppressWarnings("unchecked")
 473         OptionListModel<E> clone = (OptionListModel)super.clone();
 474         clone.value = (BitSet)value.clone();
 475         clone.listenerList = new EventListenerList();
 476         return clone;
 477     }
 478 
 479     public int getAnchorSelectionIndex() {
 480         return anchorIndex;
 481     }
 482 
 483     public int getLeadSelectionIndex() {
 484         return leadIndex;
 485     }
 486 
 487     /**
 488      * Set the anchor selection index, leaving all selection values unchanged.
 489      *


< prev index next >