Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding getMinimumSize() and GridBagLayout  RSS feed

 
Lola Slade
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a project where I have a single instance of a subclass of java.awt.Button in a frame using GridBagLayout. I have overridden getMinimumSize() and getPreferredSize() in the Button to return the same value "new Dimension(220, 180)". I add the Button to the frame using all default GridBagConstraints values except with an Insets of 50,50,50,50. I call pack() on the frame before setting it visible. When I run the project, I have two problems:
1) The Button is displayed with the correct Insets but is not
220 x 180 pixels as I have specified in getMinimumSize. It is only big enough to hold the text label. Doesn't GridBagLayout call getPrefferedSize to determine the initial size?
2) If I resize the frame to a value small enough to encroach on the insets the Button resizes to fill the whole frame either vertically, horizontally or both. Shouldn't the LayoutManager stop me from resizing the frame to a size smaller than the Button's size plus its Insets by using the getMinimumSize() method of the frame?
Thank you in advance for any help you can offer,
Lola Slade
 
Pete Bullock
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm curious about this too. Did you ever figure it out, Lola?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!