Can you post the code you are having trouble with?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Here is the listener, all you need to do further is get the selected value of the combo (within the actionPerformed(ActionEvent e) method )and then change the colour of the background based on that value!
myCombobox.addActionListener (new ActionListener () {
public void actionPerformed(ActionEvent e) {
//change back ground colour
}
});
Hope that helps!
majestic0110
Nearly a Posting Virtuoso
1,332 posts since Oct 2007
Reputation Points: 256
Solved Threads: 72
Skill Endorsements: 4
if(e.getSource()==change.getSelectedIndex())
e.getSource() is the object where the event happened
change.getSelectedIndex() is the line that's currently selected
these are two quite different things, and will never be equal.
You probabaly want something more like:
if(e.getSource()==change) { // use clicked in the change object
int selectedLine = change.getSelectedIndex(); // this is the number of the selected line
// change background colour
...
JamesCherrill
... trying to help
8,514 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30