Forgive my audacity, but this time my question is about logic.
I have two forms (classes) that interact with each other. The main one has a set of containers that in each item has a status label (starts pending) and a "multibutton" component that triggers the second form.
Depending on what you do in the second form the status of the item in the first form should change (for example to completed).
In the main form create a public method that is in charge of changing the status of the item.
When I fire the second form, I include in the constructor the object that represents the first form and in this way I can execute the public method as I please.
public class mainForm extends Form {
private container cnItem = new Container();
public mainForm() {
MultiButton mbMyButton;
mbMyButton.addActionListener ((e) -> {
setItemSelect(cn);
new secondForm (this, md) .show ();
}
}
public void changeStatus () {
changeItemStatus(getItemSelect());
}
private Container getItemSelect() {
return cnItem;
private void setItemSelect(Container cn) {
cnItem = cn;
}
}
public class secondForm extends Form {
public secondForm (MainForm mf, ModelDato md) {
if (md.condition) {
mf.changeStatus ();
}
}
This works for me, but I have always thought that there must be a more orderly way.
I thank you if you can point me to a better form of logic.
Thanks.