• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

GridBagKLayout problem

 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a simple panel with text fileds & a button arage in to a row.
The button must have a fix size and must be allway on the right side.
The text field must be resible and must fill the space between the left border & the right component(the button).
I try to use the GridBagLayout but it seamns that the cells have the same size(width & height) and I can not place the button on the right exteme.
I try for the text field the const.
cst.gridwidth = GridBagConstraints.RELATIVE; (next to end)
and for the button
cst.fill = GridBagConstraints.NONE;
cst.anchor = GridBagConstraints.NORTHWEST ;
cst.gridwidth = GridBagConstraints.REMAINDER; (the end) but there is still a lot of space between the button and the right limit.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use the cst.weightx(y) = 1.0(0) the stuff seans to work
For more info see also the :
http://javaalmanac.com/egs/java.awt/gridbag_Stretch.html?l=rel
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!