CBSE BOARD XII, asked by Sharvikaushik, 1 year ago

2. (a) Name the method used to extract value of Index
while using ListBox in Java.​

Answers

Answered by ranjeetaagarwal12
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