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