Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying TextFields in panels

 
luke patte
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
luke patte
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers that worked a treat.
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!