Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Problem with components in GridBagLayout  RSS feed

 
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have problem with JLabel and JTextfield not taking up horizontal space as I planned. Something shrink them down, and broadening the panel or frame does not help with that.
Please help me with understanding why those those things doesn't work and what to do to fix that thing.
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's screenshot of my app
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
,
Screen-Shot-2017-10-12-at-02.04.22.png
[Thumbnail for Screen-Shot-2017-10-12-at-02.04.22.png]
 
Rancher
Posts: 2974
20
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use setPreferredSize() on any component.

Each component is responsible for determining its own preferred size.

It is the job of the layout manager to determine the preferred size of a panel based on the preferred size of the components added to the panel.
 
Marshal
Posts: 61720
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to you and all of the folks!  And thanks for the tip of course.
I'm happy to be in this place with similar feeling, when you  travel somewhere and spot previous unknown, amazing place on the way to destination

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!