It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes Hidden textfields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Hidden textfields" Watch "Hidden textfields" New topic

Hidden textfields

Dmitry Danilov
Ranch Hand

Joined: Jan 27, 2004
Posts: 38
Hi there,
Does anybody know if there's a technique for storing/reading values in hidden fields on a Swing form, similarly to how hidden input fields work in HTML?
I just tried using a JTextField, which I simply set invisible by calling setVisible(false). It worked perfectly for me, but I'm just not 100% sure if this technique is clean enough and there will be no unwanted side effects etc.

[ January 20, 2006: Message edited by: Dmitry Danilov ]
Joe Ess

Joined: Oct 29, 2001
Posts: 9190

The architecture behind Swing is the idea of model-view-controller. The Model contains the data. The View presents one possible representation of the data. Want "hidden" fields? Code the View so that it does not show them.
Hidden fields in HTML are a kludge to preserve data because HTTP doesn't persist data between requests. They are not necessary when working with Java/Swing as it has more sophisticated functionality.

[How To Ask Questions On JavaRanch]
Dmitry Danilov
Ranch Hand

Joined: Jan 27, 2004
Posts: 38
Thanks for your reply, Joe. Gotta think it over now...
I agree. Here's the link:
subject: Hidden textfields
It's not a secret anymore!