Make 2 JButtons Equal in size
-
29-10-2019 - |
Question
I have two JButton
s with texts "Ok" and "Cancel". I am using GridBagLayout
to align them in a JDialog
. I have set the anchor to GridBagConstraints.CENTER
. Due to the difference in the number of characters in the texts "Ok" and "Cancel", the buttons are of different sizes. How do I align them correctly so that each of them have the same size. I tried the following but no avail.
okayButton.setSize(cancelButton.getSize());
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow