001 package sharpster.client.gui;
002
003 /**
004 * <p>Title: </p>
005 * <p>Description: </p>
006 * <p>Copyright: Copyright (c) 2003</p>
007 * <p>Company: Kafka</p>
008 * @author Tommy Eriksson
009 * @version 1.0
010 */
011
012 import java.awt.*;
013 import java.awt.event.*;
014 import javax.swing.*;
015
016
017 /**
018 * Create a SINGLE_SELECTION ListSelectionModel that calls a new
019 * method, updateSingleSelection(), each time the selection
020 * changes. This can be a little bit more convienent than using the
021 * ListModels ListSelectionListener, since ListSelectionListeners
022 * are only given the range of indices that the change spans.
023 */
024 public class SingleSelectionModel extends DefaultListSelectionModel {
025 public SingleSelectionModel() {
026 setSelectionMode(SINGLE_SELECTION);
027 }
028
029 public void setSelectionInterval(int index0, int index1) {
030 int oldIndex = getMinSelectionIndex();
031 super.setSelectionInterval(index0, index1);
032 int newIndex = getMinSelectionIndex();
033 if (oldIndex != newIndex) {
034 updateSingleSelection(oldIndex, newIndex);
035 }
036 }
037
038 public void updateSingleSelection(int oldIndex, int newIndex) {
039 }
040 }