java - Walk-around to actionPerformed() returning void -


I am trying to use the MVC design.

In the model I wanted a method like this

  Public Boolean Conversion Some Data (...) {Boolean B; // Create a dialog with a fine button returns; }   

I want to correct the way the changes are made, the change is done in the verb, the method used in the right button.

My problem is that I can not write b = true; As an OK button in the action, because I have to declare B. in final form to use it in the implementation ().

What I have been doing is making the class

  Private class Mybolian {Boolean B; }   

and then

  public boolean changes some data (...) {myboli myubian; // Create a dialog with an OK button action () {// Data changes myBoolean.b = true; } Boolean B = myBoolean.b; Return b; }   

But I do not like about this solution and I wanted to know that it is true that what I did and if there was a better solution. Should I make a better exception if the changes were not made? (For example, if the user clicks on "Cancel" instead of "OK")

< P> In the model I wanted a method like this ... // Create a dialog with an OK button

I can say that this is a flaw, because the model is considered Should not do anything with direct.

There will be a better way to open the dialog (by using the controller), register the controller for the "OK" action-action (and thus actionbased ) and then

Edit:

You may want to consider the following rejected approach:

The idea registers self or affiliated classes as the listener In the model whenever the model changes, then it changes the idea of ​​change Introduces fire to incidents.

The controller registers itself on ideas and when the idea changes, if a user changes the data, then the administrator can then open the dialog and only the user signals the commitment to "OK", thus The model is never able to check itself, if the data needs to be changed. This is actually the function of the controller and if the controller passes a change in the model, then it should be implemented.

Comments