Doubt on JList. Please read it and reply me n coding part... Please....
in case of combobox we use item listener to focus or scroll the widow automatically according to the user input through key board
dirList = new JComboBox(a);
dirList.addItemListener(listener);
My questin is how the same action can be done in the case of Jlist.
For JcomboBox there is addItemListener (to focus or scroll the widow automatically according to the user input through key board)
In case of Jlist what method is used to focus or scroll the list widow automatically to the location according to the user input through key board. Please help me out.
# 1
The following code is in JcomboBox. i.e., srolling is done in Jcombobox.
public class ItemTest {
public static void main(String args[]) {
JFrame frame = new JFrame();
Container contentPane = frame.getContentPane();
ItemListener listener = new ItemListener() {
public void itemStateChanged(ItemEvent e) { }
};
String flavors[] ={ "Apple","Bannna","Chillies","Deepak","Thiru","Shiva","Sharath","jeyastin"};
JComboBox jc = new JComboBox(flavors);
jc.addItemListener(listener);
jc.setMaximumRowCount(4);
contentPane.add(jc);
frame.pack();
frame.show();
}
}
Plese tel me. How the same program output is implented using Jlist (with the same automatic scrolling) Please tel me soon guys.....