hi. I have a jlist on a frame. I want to add items dynamically in the list. So, I am using DefaultListModel..Here's my code:
public class AdminFrame extends javax.swing.JFrame {
private Statement S;
private ResultSet R;
DefaultListModel model = new DefaultListModel();
JList Employee_list = new JList(model);
/** Creates new form AdminFrame */
public AdminFrame() {
initComponents();
MySQLConnector dbc = new MySQLConnector();
S = dbc.connectdb();
Employee_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Employee_list.setSelectedIndex(0);
Employee_list.addListSelectionListener((ListSelectionListener) this);
on_load();
}
I want to get the item selected in the list. How do I do that?
Thanks...