ucas 0 Newbie Poster

Hi. I need some help. Below is given a snippet of Java code.

deptList = new JList(deptName);
        add(new JScrollPane(deptList));
        deptList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);         
        deptList.addListSelectionListener( listSelectionListener); 
      }          
        ListSelectionListener listSelectionListener = new ListSelectionListener() {       
            public void valueChanged (ListSelectionEvent e) 
            {       
             if (e.getValueIsAdjusting()== false);
             callback.tell(dept[deptList.getSelectedIndex()]);           
             }
            };

When you run it, it creates 2 windows. When you select a value in one window it shows the associated value on another window. The problem is, that upon selecting a value (text) in one window, on another window are produced 2 outputs, two strings, of the same value.
For an instance, on one window you select 'computing', then on another window shows up 'computing' and once again 'computing'. So that's wrong!. Suppose to be just one word 'computing'.
That's when you press a mouse, you are getting value 'computing' and when you release a button of mouse, is shown a word 'computing' one more time.
How to resolve this problem?

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.