I am new to Java and I am trying to create a GUI application with some shortcuts, buttons and text fields. The program is pretty simple, and I just wanted to use the default layout, which is FlowLayout. I managed to put everything and everything in order, but the only thing that does not seem to work is alignment. I want to place buttons and text fields with certain alignments, but whenever I set the alignment, it moves the text inside the whole object, not the object itself. For example, I wrote:
button.setHorizontalAlignment(JButton.RIGHT);
but it looks like it aligns the text inside the button, not the button itself. Is there a way to align the button itself, and not the text inside?
I know that the alignment element may be easier with some other type of layout (e.g. BoxLayout), but I just want to use FlowLayout for this if it is not possible to coordinate using FlowLayout (which I don’t think so).
Thanks in advance.
source
share