aspose file tools*
The moose likes Java in General and the fly likes A better structure for the classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A better structure for the classes" Watch "A better structure for the classes" New topic
Author

A better structure for the classes

Nick White Ro
Greenhorn

Joined: Jan 27, 2010
Posts: 15
Hi,
I have some experience with Java "classic" web applications, some with console apps, but almost none regarding desktop, event based, GUI applications.

I am working on a web application using GWT and Ext GWT, which is "event based" instead of "request based". So it looks more like a desktop application than a web application.

I have a window that contains a lot of components. This is the component structure (not all of them) and the attachment shows it all:



The problem is that the components interact with each other, for example:
- A button in the ToolBar modifies the right ContentPanel by adding the proper FormPanel to it. It may possible alter the TreePanel too.
- By selecting something from the TreePanel, it modifies the buttons in the ToolBar behaviour. At the same time, it modifies the right ContentPanel by adding the proper FormPanel to it.
- A FormPanel modifies the TreePanel structure.

So the problem is organizing the components in the class. This is the current class structure:



As you can see, I have to keep a reference to the window on each component that needs to interact with another. There has to be a better way.
The source file is already over 500 lines of code long and it's not finished yet.


[Thumbnail for Component layout.PNG]

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
What happens if you use the getParent() method on each Component?
Nick White Ro
Greenhorn

Joined: Jan 27, 2010
Posts: 15
I get the parent Widget.
To get the parent window from the tree, I have to call
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
. . . And what about the getAncestors() method?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A better structure for the classes
 
Similar Threads
JSP in Struts
Scroll panel problems
Event problems
First GUI program
Populating textbox with the selected item from the pop-up window