Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Question about generic swing JFrame structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question about generic swing JFrame structure" Watch "Question about generic swing JFrame structure" New topic

Question about generic swing JFrame structure

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
I have a number of JFrames within an application and I'm to promote re usability by being easily able to add panels to these JFrames to cause the least disruption to users. There is a common panel across all JFrames and it is the bottom panel with a connect and exit button. I have a problem though. Say within a JFrame, I have 2 panels, 1 with a number of textfields that must be validated and the other panel is the bottom panel. I perform my validation in the bottom panel using the start and stop buttons. I tried to make the bottom panel generic and place the validation code in the textsfields panel. But when I called the validation code from the bottom panel which resided in the textfields panel, the validation code knew nothing about changes to the textfields, therefore at this stage, I presume the validation code must reside in the Jframe itself. What I would like to know now is, if I make a panel within JFrame(s) generic, how can I call the validation code from the generic JPanel which resides in the JFrame and is this my only possibility. This is just a private project, any help appreciated.
Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
Too long / comblicated explanation makes me sleepy, but

If I get this right the main problem here is the validation... how to do it properly and make it easy.

I Had problems with validation...
I was uncertain that how the validation progress is done properly and I shall share my experience and search on it... which is short

- Text Field Auto Tab - by Rob Camick, you get the picture from SizeDocumentFilter to do similar filters and using them as chains.
- Building a Swing Validation Package with InputVerifier - old but you get the message and modify it for your needs.

And I combined a bit of these two great examples i.e. bringing WantsValidationStatus to Rob's example etc.
It is sorta covered in the JavaRanch Style Guide.
subject: Question about generic swing JFrame structure
Similar Threads
validate(), remove()- what do they REALLY do?
Space around my BorderLayout
Problem with GridBagLayout and a vertical layout of JPanels
Adding Panels in Frame or in a Panel
How to reflect an event that occurs in a bean to an applet which holds the bean ?!!