Re: GUI components creation idioms

Tomas Pavek <[email protected]>
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>
There is no support for generating additional data structures for components 
(automatically). It would be possible to implement, however I'm not sure how 
common such a need is, or if it is actually the primary problem to be solved. 
Isn't the original need something like to have a way to bind components to 
some data sources?

I'm also afraid that in case of generating a map like EnumMap<FieldAttribute, 
JTextField>), you'd have to specify the key for each component somehow, which 
might actually require quite the same time spent clicking in the UI as writing 
the simple code manually. Note you probably don't need to use the 
post-creation code of each component separately - you can write the whole code 
for all components at once in the constructor after initComponents() call.

   - Tomas


King Lung Chiu wrote:
> Hi again,
> 
> Usually when I create a form, there are multiple components of the same
> type, eg. 5 combo boxes, or 5 text fields, and Netbeans creates a new
> variable for each of those components.
> 
> I'd like to have them created as items in a data structure (eg. an array or
> ArrayList or HashMap of combo boxes),to make it easier to reference them
> later. Is there an automatic way to do that?
> 
> My current workaround is to create the data structure myself (eg.
> EnumMap<FieldAttribute, JTextField>), and manually add the components to
> that data structure in each comopnent's post-creation code (in this case,
> maping each component to its corresponding enum value). However, this method
> doesn't scale when I have a large number of components to add. (lots of code
> copy + paste + small-edit).
> 
> Any comments welcome, thanks
> 
> King
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.