File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes static JTextField problem! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "static JTextField problem!" Watch "static JTextField problem!" New topic
Author

static JTextField problem!

Antigoni Splash
Greenhorn

Joined: Jun 12, 2009
Posts: 10
I have created a form for users to complete multiple of them and using some buttons can go back and front between forms... But i have a problem! I have some static fields that i want them to appear on every form and the changes made to them affect all forms, but when i go back to a previous form the fields appear for a sec and then leave immediately! That doesn't happen when i am moving forward...

Any ideas why is that?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Components can only have a single parent. You can't add the same component to more than one panel. It only appears like its working as you move forward because you don't see it being removed from the previous panel until you go back to that panel.

You should be able to create multiple components, but share the model. For example with a text field you can do:

Antigoni Splash
Greenhorn

Joined: Jun 12, 2009
Posts: 10
oh ok!
But is there a particular reason why a component canno't be added twice?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Antriani,

Please read your private messages.

Thank you,

Rob


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> But is there a particular reason why a component canno't be added twice?

read the first sentence of the first reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static JTextField problem!
 
Similar Threads
Setting data to more than one form
Validation for included forms.
form values not updated
html file with multiple form elements
Jasper Reports - Problem while viewing report in JSP