Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pack() method in JFrame

 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I've seen many examples that invoked pack() method but the others didn't and only invoked setVisible(true). I don't understand that when the pack() is invoked, can anyone tell me?
Thank you.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pack is used when you are using layout managers and you want the JFrame to be the smallest size showing all components. If you set the size of your JFrame manually ( setSize(), setBounds() ) then you don't need to call pack().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic