Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i design/code for optional features?

Status
Not open for further replies.

shackman01

Programmer
Nov 7, 2003
1
US
i am developing a java application that has a primary function and additional optional ancillary features. i want to be able to enable just the optional features that the customer wants. the problem i'm having is that my panels need to reflect only those features that are installed. say a panel has 3 components. component 1 is used regardless of what optional features are enabled. component 2 is only shown and used if optional feature A is enabled. component 3 is only shown if both features A & B are enabled. and so forth.

i don't want to have 3 or more versions of the same panel having just the relevant components. i thought about having some global booleans and using if statements in my panel construction and validation logic, but that's a maintenance nightmare. there's got to be a better way. what do you suggest?

Floyd Shackelford
 
Some suggestions :

1. Use subpanels for the optional components
2. Use tabbed panes for the optional components
3. PS : The following is probably not very clear, but maybe it gives you an idea.
If you don't want to use may if statements or switch/case, you have to treat you components on a 'generic' basis. You could
- make a wrapper class around JComponent (and/or use the client properties of JComponent)
- create your wrappers containing your components and add those components to a Vector or something like that
- then you can code a for loop to run over those components and add them to the screen
- for retrieving them from the screen and validating them you can do something similar

If your screens are simpler [e.g. Label/Value pairs], there are probably easier solutions. [ Depending on which LayoutManager you want/can use ].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top