Separating form code in a JFrame Class

I am working on a desktop program (Multi frame app) where i have a form with several JTextFields and a Button. First I created one JInternalFrame and placed all form elements there but later I found that i need to create exactly same form on a different JInternal window. So tried to separate the form code from Frame code and create another class (Sub-Class of JComponent) so that i can reuse the form code. But my code is not working properly

here is the simple code

-- Window Class --

-- Form Class --

Here i cannot see the textfield in the widow after running but its invisibility present there..I came to know this when i click on the window everywhere and textfield area started appearing....similar thing happens when i have several textfields some appear and some dont.

Like most newbies your problem is that you are NOT using a Layout Manager. Forget about trying to use a "null layout" and learn how to use Layout Managers.

Read the section from the Swing tutorial on Using Layout Managers. The tutorial is full of examples to get you started with proper Java coding techniques.

Also, learn to use proper class names. Class names should be upper cased.

Abhishek Kaushik
Greenhorn

Joined: Mar 03, 2010
Posts: 14

posted Mar 03, 2010 18:26:18

0

Thanks Rob,

I will try to learn Layout Managers. I had removed "null" layout from the code and it should run with default FlowLayout ....but i see no difference in result. I guess it has more to do with the following cases. I tried that too but partial success only..