• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

2 Questions

 
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Cowpokes...
I have 2 questions for you.
1.) What is the rule for when you need to use _ to extend a line to the next line?
2.) I have read in RHE that FlowLayout always honors a components preferred size. However, in the code on page 269, they demonstarte that if you try to use setBounds to make a Button really big, it won't work (unless you set the layout manager to null). I understand that the setBounds call gets
wiped out by the layout manager (in this case, it's in an Applet, so flowlayout), but if flowlayout always honors a components preferred size, how come attempts to make thebutton large in this way fail?

Thanks.
Matt
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Regarding question No 2
You can use setBound() method only when you setLayout(null)
It will not work with other layout managers. If you try to use it will simply ignore it with other layout managers..
solaiappan
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No disrepect intended, but, yes, I understand that perfectly. That's not what I was asking (and if you read my post carefully, you'll see that I say that EXACT same thing in my post).
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Matt:
Please check this out and see if this would be useful.
If a container has an associated layout manager, the container asks that layout manager to position and size its components before they are painted. The layout manager itself does not perform the painting; it simply decides what size and position each component should occupy and calls setBounds(), setLocation() and/or setSize() on each of those components

So, though you call setBounds() method to resize the component, when it is actually painted, it is the call to setBounds() by the Layout manager that matters. And as you know the flow layout retains the component's preferred size!! (for a button, it is just the size wide enough to hold its label + white spaces etc.) Hence, the resizing you do does not really matter.
HTH
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OH! That helps a lot. I understood about how the layout manager calls setBounds itself and wipes out the setbounds called beforehand, however I didn't realize that a button's (or other component) preferred size is just wide enough to hold the label and so on. OK, thanks. That makes sense now.
With Respect,
Matt
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic