2. (a) Name the method used to extract value of Index
while using ListBox in Java.
Answers
Answered by
0
Answer:
1)Create a class that extends JFrame and implements ActionListener interface.
2)Create an array of objects. These will be the values of the JList.
3)Create a new JList with the above array.
4)Create a new JButton. Add an ActionListener to the button and override the actionPerformed method. Now every time the user presses the button this method will fire up.
5)Call getSelectedIndex to get the index of the selected item in the JList.
6)Call getSelectedValue method to get the value of the selected item in the JList.
Similar questions
English,
6 months ago
English,
6 months ago
Environmental Sciences,
1 year ago
English,
1 year ago
Chemistry,
1 year ago