wood burning stoves*
The moose likes JavaFX and the fly likes Problems with GUI design and eventhandling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Problems with GUI design and eventhandling" Watch "Problems with GUI design and eventhandling" New topic
Author

Problems with GUI design and eventhandling

Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 140


I have some problems with my design for the presentation layer of my application. Let's assume there are two screens. First a login screen, and then a main screen is shown when the user logs in successfully.

The application looks like:

GUI <---> Business/service layer <---> Server <---> Database

To first simplify the problem let's remove the server layer.

GUI <---> Business/service layer <---> Database

The business layer can now access the database directly. Logging in from the GUI would simply be something like:

SomeReturnObject s = myGUIClass.getBusinessLayerClass().doLogin(...)
From here I can update the GUI if I want.

When we add the server layer again (that uses Sockets for communication between the server and its clients), the situation isn't much more difficult IF the business layer login method does something like:

- create a request
- write the request to the server
- receive the response from the server for this request
- return the response to the caller

But this is not the way I want it to be. My GUI will have more events that are send to the server and some of them should update other parts of the GUI. Compare it to the idea of an asynchronous call, where the login method example above was a synchronous call, because the response was received in the same method.

So my first question is: How do I setup my design such that data/events/responses from the server are properly handled in my GUI (in a single place?) in such a way that every desired node can be updated?

And my second question is about stages and custom nodes. What's the best practice in JavaFX: create one stage and update it's scene/content or create a new Stage for every screen (like one for login screen and one for main window). The problem with using a custom node (class that extends Parent) is that I can't close the window, because of this:


Let's say loginNode has an FadeTransition that should close the stage when finished. It can't now...

Any ideas / suggestions are welcome.

Cheers,
Dennis


SCJP, SCWCD, SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with GUI design and eventhandling