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() {
        MySQLConnector dbc = new MySQLConnector();
        S = dbc.connectdb();

        Employee_list.addListSelectionListener((ListSelectionListener) this);

I want to get the item selected in the list. How do I do that?

hi. well, nothing wrong with getselecteditem()....jst dint knw where to write that statement...
But hey, it works now.
However, I think its invoking the listener twice.
my code:

private class ListListener implements ListSelectionListener {
        public void valueChanged(ListSelectionEvent e) {
             String emp_name = Employee_list.getSelectedValue().toString();
    }//class ListListener ends

emp_name is printed twice.

Without seeing all the code, my best answer is "don't know". Sorry