List Class In AWT in Java

0
47
Spread the love
  • 23
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    160
    Shares

List Class In AWT in Java

List class is a Component that graphically displays a list of strings. The list is scrollable if necessary. The constructor takes optional arguments that specify the number of visible rows in the list and whether the selection of more than one item is ured allowed. The various instance methods allow strings to be added and removed from the list and allow the selected item or items to be queried.

The definition of List Class is given as


public class java.awt.List extends Component implements java.awt.ItemSelectable{
// Public Constructors
public List();
public List(int rows);
public List(int rows, boolean multipleMode);
// Public Instance Methods
public void add(String item);
public synchronized void add(String item, int index);
public synchronized void addActionListener(ActionListener al);
public void addItem(String item);
public synchronized void addItem(String item, int index);
public synchronized void addItemListener(ItemListener il);// From ItemSelectable
public void addNotify();// Overrides Component
public boolean allowsMultipleSelections();
public synchronized void clear();
public int count Items();
public synchronized void delItem(int position);
public synchronized void delItems(int start, int end);
public synchronized void deselect(int index);
public String getItem(int index);
public int getItemCount();
public synchronized String [ ] getItems();
public Dimension getMinimumSize(int rows);
public Dimension getMinimumSize();// Overrides Component
public Dimension getPreferredSize(int rows);
public Dimension getPreferredSize();// Overrides Component
public int getRows();
public synchronized int getSelectedIndex();
public synchronized int [ ] getSelectedIndexes();
public synchronized String getSelectedItem();
public synchronized String [ ] getSelectedItems();
public Object [ ] getSelectedObjects();// From ItemSelectable
public int getVisibleIndex();
public boolean is IndexSelected(int index);
public boolean isMultipleMode();
public boolean isSelected(int index);
public synchronized void makeVisible(int index);
public Dimension minimumSize(int rows);
public Dimension minimumSize();// Overrides Component
public Dimension preferredSize(int rows);
public Dimension preferredSize();// Overrides Component
public synchronized void remove(String item);
public synchronized void remove(int position);
public synchronized void removeActionListener(ActionListener al);
public synchronized void removeAll(); 
public synchronized void removeItemListener(ItemListener il) //From ItemSelectable ();
public void removeNotify()// Overrides Component
public synchronized void replaceItem(String newValue, int index);
public synchronized void select(int index);
public synchronized void set MultipleMode(boolean b);
public synchronized void setMultipleSelections(boolean b);//protected method
protected String paramString();// Overrides Component
protected void processActionEvent(ActionEvent e);
protected void processEvent(AWTEvent e);// Overrides Component
protected void processItemEvent(ItemEvent e);
}
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 23
  • 34
  • 56
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    160
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here