• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resize JPanel vertically instead of inner components  RSS feed

 
Chaz Branham
Ranch Hand
Posts: 53
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning, Afternoon or Night wherever you are

Its been a little while since I have been back here but I am glad to say I have made huge strides in learning JAVA (YEAH!). I am however curious/stumped on an issue where my JPanel when adding components to it will never make its self larger but it will make my components inside smaller even though I have set the minimum and preferred sizes for those components? I am using the GridBagLayout for my layout manager as I am trying to get used to it.

If anyone wouldn't mind taking a few seconds to read through the code I'm posting and offer some help I would greatly appreciate it. All I need the JPanel to do is to resize itself vertically keeping the components inside the same size.




Thank you for your help and time.
 
Chaz Branham
Ranch Hand
Posts: 53
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case anyone is interested I was able to fix the issue. It was due to my scaling code where I set the PreferredSize of the JPanel. This seems to always force the JPanel back to the original size no matter how many components are in it. The way I overcame this was by setting the initial size of the object but then based on how many ever rows were used in my GridBagLayout then it would give enough room to make it look nice and not so squished. Here is the code:



I will need to change the code a bit for different resolutions but that won't be that bad since my scaling code can take care of it for me.

Have a good one.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!