Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing: adding components later  RSS feed

 
John Shade
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a program that first uses a KeyListener and that all goes well and fine. but after a certain number of keypresses I want a slider and button to appear. I've tried just about everything: creating the later components at the beginning and then hiding them (then making them appear), creating the components as I need them, etc. etc. However, I've been unable to get the components to appear when I need them. It seems they go into a blackhole after being hidden or disabled...any suggestions?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suggestion #1: Post SWING questions in the SWING Forum
Suggestion #2: When adding and removing components during runtime, you need to call validate() on the Component where the removing and adding is taking place.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, John!
I'm moving this to the Swing / JFC / AWT forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!