I have this sample:
Class MyComp{
private final CheckBox checkbox;
public Registration addMyEventListener(
ComponentEventListener<MyEvent> listener) {
return addListener(MyEvent.class, listener);
}
public MyComp(int value){
checkbox.addValueChangeListener(evt-> fireEvent(new MyEvent(this, true, evt.getValue()));
}
}
Class view {
private final MyComp myComp;
public View(){
myComp.addMyEventListener(item -> System.out.println("teste");
}
}
So when my user click on my checkbox. the System.out.print are executed.
But now I need to change in my MyComp constructor to if the value > 10 for sample the checkbox need to start checked so I put one
public MyComp(int value){
checkbox.addValueChangeListener(evt-> fireEvent(new MyEvent(this, true, evt.getValue()));
checkbox.setValue(value > 10)
}
But when I does this the System.out. dont run… how can I fix this? I already try to fire the event just like this:
if(value > 0)
fireEvent(new MyEvent(this, true, evt.getValue()))
but without success too…
can anyone help me?
tks