Java / gwt UI Encoding - Pure Code

I started with some basic java coding with gwt and I am a little worried about my main class.

For example, as one separation of key manipulators, since they cause a number of changes in the user interface, how can I move this to a separate .class file and still have access to all the widgets in the main class, without having to pass everything to the handler (i.e., everything widgets that I manipulate after the click event).

I searched googled but did not come across any particularly good examples - do I know of any easily readable code bases that I could read to see how to do this? (gwt own tuts are pretty simple, and just a kitchen - pushing every thing into one file)

thank!

+2
source share
2 answers

I hate saying something so unimaginable, but MVC works - it's not final, but it may start organizing you.

EDIT: while searching for a topic related to gender, I came across this , which has similar ideas for mine, but in more detail.

What this means from the point of view of GWT is that you should think about simply decomposing the GUI components in one class, moving all the event processing in a second and placing the object model objects separately from the other two.

- GUI. , , , - /, , .

:

. , , . / , . , , - "" , , . , - , , - , , .

GUI Trick, , -, GUI -, , , . , . , , .

:

GUI - . , , . , , , , , , , ​​ - 3 ( , ).

"" , - . , , , , . XML-. , .


MVC:

, , MVC MILLION.

MAIN:

  • MyView
  • MyModel
  • MyController (myView, myModel)
  • myView.setVisible()

MyView

  • Frame
  • (public final Button b = new Button())
  • , getters - EXACT-, .
  • , .
  • , reset(), MyController .

MyController

  • myView myModel
  • myView, (. ).
  • myView myModel
  • "done" myView myModel
  • myModel , .

MyModel:

, - ( , GUI MyController. -, updated(), - . GUI - "" -.

GUI update() - , - - ...

, , MyController, - , , .

, View Controller . Swing - , - .

+7

Source: https://habr.com/ru/post/1734117/


All Articles