home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / jfc.bin / ListSelectionEvent.java < prev    next >
Text File  |  1998-02-26  |  3KB  |  98 lines

  1. /*
  2.  * @(#)ListSelectionEvent.java    1.9 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.event;
  22.  
  23. import java.util.EventObject;
  24. import com.sun.java.swing.*;
  25.  
  26.  
  27. /** 
  28.  * An event that characterizes a change in the current
  29.  * selection.  The change is limited to a row interval.
  30.  * ListSelectionListeners will generally query the source of
  31.  * the event for the new selected status of each potentially
  32.  * changed row.
  33.  * <p>
  34.  * Warning: serialized objects of this class will not be compatible with
  35.  * future swing releases.  The current serialization support is appropriate
  36.  * for short term storage or RMI between Swing1.0 applications.  It will
  37.  * not be possible to load serialized Swing1.0 objects with future releases
  38.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  39.  * baseline for the serialized form of Swing objects.
  40.  *
  41.  * @version 1.9 02/02/98
  42.  * @author Hans Muller
  43.  * @author Ray Ryan
  44.  * @see ListSelectionModel
  45.  */
  46. public class ListSelectionEvent extends EventObject
  47. {
  48.     private int firstIndex;
  49.     private int lastIndex;
  50.     private boolean isAdjusting;
  51.  
  52.     /** 
  53.      * Represents a change in selection status between firstIndex
  54.      * and lastIndex inclusive (firstIndex is less than or equal to 
  55.      * lastIndex).  Atleast one of the rows within the range will
  56.      * have changed, a good ListSelectionModel implementation will
  57.      * keep the range as small as possible.
  58.      * 
  59.      * @param firstIndex The first index that changed.
  60.      * @param lastIndex The last index that changed, lastIndex >= firstIndex.
  61.      * @param isAdjusting An indication that this is one of rapid a series of events
  62.      */
  63.     public ListSelectionEvent(Object source, int firstIndex, int lastIndex,
  64.                   boolean isAdjusting)
  65.     {
  66.     super(source);
  67.     this.firstIndex = firstIndex;
  68.     this.lastIndex = lastIndex;
  69.     this.isAdjusting = isAdjusting;
  70.     }
  71.  
  72.     /**
  73.      * @return The first row whose selection value may have changed.
  74.      */
  75.     public int getFirstIndex() { return firstIndex; }
  76.  
  77.     /**
  78.      * @return The last row whose selection value may have changed.
  79.      */
  80.     public int getLastIndex() { return lastIndex; }
  81.  
  82.     /**
  83.      * @return True if this is one of a rapid series of events
  84.      */
  85.     public boolean getValueIsAdjusting() { return isAdjusting; }
  86.  
  87.     public String toString() {
  88.     String properties = 
  89.         " source=" + getSource() +  
  90.             " firstIndex= " + firstIndex + 
  91.             " lastIndex= " + lastIndex + 
  92.         " isAdjusting= " + isAdjusting +
  93.             " ";
  94.         return getClass().getName() + "[" + properties + "]";
  95.     }
  96. }
  97.  
  98.