I want to create buttons for a GUI that have 3 different fixed sizes. I want the size of the buttons to be independent of the String
inside them. Is that possible with GridBagLayout
?
As an alternative, consider using an available sizeVariant
, illustrated here.
If you pursue a custom ButtonUI
approach, shown in the last row, please ensure that the resulting buttons are no smaller than their preferred size. Doing so in your implementation of getPreferredSize()
will help avoid the pitfall seen here.