I have a problem with the gui main window layout. On the centre of the screen is a JTable and below to the right are two buttons called Search and Book. The trouble is, the size of the width of the search button is longer than the Book button. I tried getting the size of the search button and then passing this down to the book button but this does not change the width of the book button.
If you are creating two buttons with the titles OK and Cancel, as a default each of the buttons will size accordingly to the length of their titles. To remedy this, for each of the buttons, call its setPreferedSize method passing in dimensions of width and height to be of the same lenght as each other and buttons OK and Cancel will be of the same size.
I'm delighted as to how easy this was, and I'm replying to this topic in the case that any of the other ranchers are having the same trouble.
I don't know if buttons having same width is something where you want to add extra lines for. I just stuck with the FlowLayout and the width depending on the caption of the button.