*
The moose likes Swing / AWT / SWT and the fly likes Displaying TextFields in panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying TextFields in panels" Watch "Displaying TextFields in panels" New topic
Author

Displaying TextFields in panels

luke patte
Greenhorn

Joined: Jan 11, 2004
Posts: 12
I have a JPanel in a JWindow with an event which creates a JTextField, however, the JTextField does no appear immediately after it is created but only appears when I resize the window. I'd like the text field to apear as soon as it is created, any ideas??
thanks
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You have to call invalidate() and validate() (and possibly repaint()) on the JPanel you are adding the new components to... if you're adding components dynamically, the layout manager doesn't re-layout the panel. invalidate() and validate() tells the layout manager to re-layout the panel.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
luke patte
Greenhorn

Joined: Jan 11, 2004
Posts: 12
Cheers that worked a treat.
 
Consider Paul's rocket mass heater.
 
subject: Displaying TextFields in panels
 
Similar Threads
i was made some mistake in gridbaglayout so pls help me
Jtext problem very urgent
keypad
Resize Problem
keypad