• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Why doesn't this work?

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why doesn't the second JTextField show up when I press the button? If I have the JTextField setVisible to true in the constructor, and set it to false in the actionPerformed method, it works, but if it starts out setVisible(false) it doesn't show up when the button is pressed.
I'm sure it's something really stupid, but I can't seem to find what it is...
Thanks so much for any help!
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a call to validate() after the line where you set the text field visible.
Jeff
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That seems to have worked. However, I am not familiar with this method. What exactly happened here when I called this method? The API didn't really float my boat...
Thanks for the help!
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whenever a container's layout needs to be reset, the invalidate() method should be called on the conatiner object.
a conatiner'r layout needs to be reset when:
1) it iself needs to be resized
2) when one or more of its components' size need to be resized
3) when a new component is going to be added
this method should be called on the components' objects (if they are involved), the conatiner and the parent container and so on upto the topmost container.
a change in layout in a child container affects the layout upto the top containment heirarchy!!
so calling invalidate() on those components or containers concerned marks them invalidate and says they need to be laid out.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for clearing that up! Make more sense now!
 
Shashi Kanta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u r welcome!
 
Our first order of business must be this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic