-
Bug
-
Resolution: Unresolved
-
P4
-
9
Not sure if a bug, but just in case...
Please run the following code:
import java.beans.*;
import java.lang.reflect.Method;
import javax.swing.JButton;
public class ListenerTest {
private static class Child extends JButton {
@BeanProperty(bound = false, description = "child's text")
@Override
public void setText(String text) { super.setText(text); }
}
public static void main(String[] args) throws NoSuchMethodException {
Child child = new Child();
child.addPropertyChangeListener("text", (PropertyChangeEvent e) -> {
System.out.println("\n>>> LISTENER: " + e.getPropertyName() + " changed");
});
Method m = child.getClass().getMethod("setText", String.class);
BeanProperty p = (BeanProperty) m.getAnnotation(BeanProperty.class);
System.out.println("setText(), bound = " + p.bound() + ":\n" + p.toString());
child.setText("ABC");
}
}
The output (JDK9 b115 + Win. 7):
setText(), bound = false:
java.beans.BeanProperty(expert=false, hidden=false, visualUpdate=false, bound=false, enumerationValues=[], description=child's text, preferred=false, required=false)
>>> LISTENER: text changed
A bound property notifies listeners when its value changes. Here the child's text property is explicitly annotated as _not_ a bound. Should this prevent from receiving the event or this is just some information for the user?
Please run the following code:
import java.beans.*;
import java.lang.reflect.Method;
import javax.swing.JButton;
public class ListenerTest {
private static class Child extends JButton {
@BeanProperty(bound = false, description = "child's text")
@Override
public void setText(String text) { super.setText(text); }
}
public static void main(String[] args) throws NoSuchMethodException {
Child child = new Child();
child.addPropertyChangeListener("text", (PropertyChangeEvent e) -> {
System.out.println("\n>>> LISTENER: " + e.getPropertyName() + " changed");
});
Method m = child.getClass().getMethod("setText", String.class);
BeanProperty p = (BeanProperty) m.getAnnotation(BeanProperty.class);
System.out.println("setText(), bound = " + p.bound() + ":\n" + p.toString());
child.setText("ABC");
}
}
The output (JDK9 b115 + Win. 7):
setText(), bound = false:
java.beans.BeanProperty(expert=false, hidden=false, visualUpdate=false, bound=false, enumerationValues=[], description=child's text, preferred=false, required=false)
>>> LISTENER: text changed
A bound property notifies listeners when its value changes. Here the child's text property is explicitly annotated as _not_ a bound. Should this prevent from receiving the event or this is just some information for the user?