FileDocCategorySizeDatePackage
AnimatedJList.javaAPI DocExample6682Mon Jan 09 11:01:58 GMT 2006None

AnimatedJList

public class AnimatedJList extends JList implements ListSelectionListener

Fields Summary
static Random
rand
static Color
listForeground
static Color
listBackground
static Color
listSelectionForeground
static Color
listSelectionBackground
static float[]
foregroundComps
static float[]
backgroundComps
static float[]
foregroundSelectionComps
static float[]
backgroundSelectionComps
public Color
colorizedSelectionForeground
public Color
colorizedSelectionBackground
public static final int
ANIMATION_DURATION
public static final int
ANIMATION_REFRESH
Constructors Summary
public AnimatedJList()


      
        super();
        addListSelectionListener (this);
        setCellRenderer (new AnimatedCellRenderer());
    
Methods Summary
public static voidmain(java.lang.String[] args)

        JList list = new AnimatedJList ();
        DefaultListModel defModel = new DefaultListModel();
        list.setModel (defModel);
        String[] listItems = {
            "Chris", "Joshua", "Daniel", "Michael",
            "Don", "Kimi", "Kelly", "Keagan"
        };
        Iterator it = Arrays.asList(listItems).iterator();
        while (it.hasNext())
            defModel.addElement (it.next());
        // show list
        JScrollPane scroller =
            new JScrollPane (list,
                            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        JFrame frame = new JFrame ("Checkbox JList");
        frame.getContentPane().add (scroller);
        frame.pack();
        frame.setVisible(true);
    
public voidvalueChanged(javax.swing.event.ListSelectionEvent lse)

        if (! lse.getValueIsAdjusting()) {
            HashSet selections = new HashSet();
            // System.out.println ("got last lse");
            for (int i=0; i < getModel().getSize(); i++) {
                if (getSelectionModel().isSelectedIndex(i))
                    selections.add (new Integer(i));
            }
            CellAnimator animator = new CellAnimator (selections.toArray());
            animator.start();
        }