• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Layout...

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To a frame, you want to add the following:
1. TextArea
2. Label
3. Button
Which layout manager will you use so that the TextArea occupies all the vertical space when the frame is resized?
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure -- but I think BorderLayout may be the best.. should use the TextArea in Center. If anybody knows it for sure, please confirm.
-- Hari Gangadharan
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried:
{
...
setLayout(new GridLayout());
add(textArea);
add(label);
add(button);
...
}
In this case, the TextArea occupies the vertical space fully. But with BoarderLayout, I think that TextArea occupies full space only if button and label are added to East and West.
Also new gridLayout(1,1) works fine. But GridLayout(2,1) does not meet this requirements.
Therefore which one is most suitable answer to this question?
Anyone, please?
Rajesh
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
I think BorderLayout is most suitable answer.
 
Dilshad Syed
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We still don't seem to have a definite answer, can someone shed some light on this one?
Someone mentioned that this question was asked on an exam which didn't give the answers at the end.
Thanks!
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajesh R,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Rajesh R
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jane,
This is my original name as it appears in my all records. I cannot change my name for the sake of re-registering(joking).
do you know a definite answer for this question?
thanks, Have a great daY!
Rajesh R

Originally posted by Jane Griscti:
Rajesh R,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.


 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dilshad,
I think there is more than one answer to the question. I would propose that the answer would be:
Any except FlowLayout.
1. BorderLayout:
Label --> East
TextArea --> Center
Button --> West
2. GridLayout:
Single row will have all comps use all vertical space
3. GridBagLayout:
TextArea --> fill constraint = GridBagConstraints.BOTH or
GridBagConstraints.VERTICAL
4. BoxLayout
Horizontal alignment of components with correct glue.
Regards,
Manfred.
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajesh,
I agree with Manfred's explanation. The question is very ambiguous; luckily, the real exam questions are much clearer
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dilshad
The answer to your question is "GridbagLayout"
The reason being - Assuming you are adding the text area at the top of the layout. So only Gridbag layout gives you the flexibility to adjust the vertical as well as horizontal space by its "weightx" and "weighty" constraints.
So the answer is definitely "GridbagLayout".
Rakesh
 
straws are for suckers. tiny ads are for attractive people.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic