Hi. I need some help. That's a snippet of the class.

public constructor ( ChooserListener callback ) {  // that's a constructor
        super();
        Loader.load();
        this.callback= callback;
        JFrame frame = new JFrame();       
        frame.getContentPane();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(this);
        frame.setSize(300,330);
        frame.setVisible(true);
        
        JPanel lectures = new JPanel();
        String items [] ={BLANK,COMP,EIMC,MATH};
        JList list = new JList(items);                
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        
         list.addListSelectionListener( listSelectionListener); 
         lectures.add(list);
}
ListSelectionListener listSelectionListener = new ListSelectionListener() { 
        
            public void valueChanged (ListSelectionEvent e) 
            {    // System.out.println(  listSelectionListener);
                System.out.println("Hooray"); 
             if (e.getValueIsAdjusting()== false)
                // tell(dept[deptList.getSelectedIndex()]);  
                  tell(COMP);  
             }
            };
} // the end of class

I can't understand why System.out.println("Hooray"); is not executed. Why execution bypasses that 'valueChanged' method. What's the problem?
Cheers

You are not attaching the list selection listener to the list. Do that and you should have your problem fixed.

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.