Reputation: 4885
When i run the code below, the fireEvent()
method is called inside the Slider class instead of the ColorPanel class. How can i make it call the fireEvent()
method in the ColorPanel class? (They both extend EventComponent which has the method)
public class ColorPanel extends EventComponent<ColorChangeListener> {
public ColorPanel() {
...
add(new ValueSlider());
}
.................more Code
@Override
protected void fireEvent() {
for (ColorChangeListener l : listeners)
l.colorChanged(color);
}
private class ValueSlider extends Slider {
public ValueSlider() {
super(0, 200, 200, 200);
this.x = 10;
this.y = 220;
addListener(new ValueChangeListener() {
@Override
public void valueChanged(int value) {
colorCircle.setValue(value / 200f);
color = colorCircle.getSelectedColor();
fireEvent();
}
});
}
}
Upvotes: 0
Views: 56
Reputation: 137322
You should specify the class like this:
ColorPanel.this.fireEvent();
Upvotes: 0
Reputation: 10239
Point the compiler to the right method by changing fireEvent();
to ColorPanel.this.fireEvent();
Upvotes: 2