This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Searching for GUI(?) pattern to display the same set of graphic elements in various ways Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Searching for GUI(?) pattern to display the same set of graphic elements in various ways" Watch "Searching for GUI(?) pattern to display the same set of graphic elements in various ways" New topic
Author

Searching for GUI(?) pattern to display the same set of graphic elements in various ways

Ismael Upright
Ranch Hand

Joined: Feb 15, 2007
Posts: 166
Hey there,

I'm using RCP to create the standalone desktop application. If you're not familiar, RCP uses SWT as graphic engine. But the question is rather about general programming pattern on how to organize the GUI code in readable way (doesn't have to be SWT code). Here we go:


I have a class which implements a composite. A composite is a rectangle that contains:

- Checkbox with text next to it
- Two radio buttons, one under another, each with text next to is; these radio buttons are active only if the checkbox above is checked
- Yet another checkbox with text next to it
- a table with some editable data
- two buttons: "create new" and "delete existing", used to create new row in table and to delete existing row from table.


The point is, the display of this composite depends on the previous user actions.

Sometimes I don't want to display radio buttone, only two checkboxes one under another, and table with buttons

Sometimes I don't want to display the table and buttons, only checkbox, 2 radios and checkbox again

Sometimes I want to display everything: checkbox, 2 radios, checkbox, table and 2 buttons



It's easy to do with lot's of "ifs" in the code but it makes the code much less readable. Maybe you know a pattern which would be useful in this case?


I need to:

- provide the information about display conditions from the outside of class (constructor? flags with setters and getters? others?)
- manage the internal code in the class in a readable way (inheritance? division of class to smaller parts? some "smart" methods for each graphic element? others?)
 
Don't get me started about those stupid light bulbs.
 
subject: Searching for GUI(?) pattern to display the same set of graphic elements in various ways