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());