FileDocCategorySizeDatePackage
FilterHistoryJList.javaAPI DocExample5411Mon Jan 09 11:01:58 GMT 2006None

FilterHistoryJList

public class FilterHistoryJList extends JList

Fields Summary
private FilterField
filterField
private int
DEFAULT_FIELD_WIDTH
Constructors Summary
public FilterHistoryJList()


      
        super();
        setModel (new FilterModel());
        filterField = new FilterField (DEFAULT_FIELD_WIDTH);
        filterField.textField.requestFocus();
    
Methods Summary
public voidaddItem(java.lang.Object o)

        ((FilterModel)getModel()).addElement (o);
    
public FilterHistoryJList$FilterFieldgetFilterField()

        return filterField;
    
public static voidmain(java.lang.String[] args)

        String[] listItems = {
            "Chris", "Joshua", "Daniel", "Michael",
            "Don", "Kimi", "Kelly", "Keagan"
        };
        JFrame frame = new JFrame ("FilterHistoryJList");
        frame.getContentPane().setLayout (new BorderLayout());
        // populate list
        FilterHistoryJList list = new FilterHistoryJList();
        for (int i=0; i<listItems.length; i++)
            list.addItem (listItems[i]);
        // add to gui
        JScrollPane pane =
            new JScrollPane (list,
                             ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        frame.getContentPane().add (pane, BorderLayout.CENTER);
        FilterField filterField = list.getFilterField();
        frame.getContentPane().add (filterField, BorderLayout.NORTH);
        frame.pack();
        frame.setVisible(true);
        filterField.textField.requestFocus();
    
public voidsetModel(javax.swing.ListModel m)

        if (! (m instanceof FilterModel))
            throw new IllegalArgumentException();
        super.setModel (m);