Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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: 2892
17
  • 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: 58828
179
  • 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!