Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make FlowLayout add components to the top of a frame instead of the center?

I am using FlowLayout and I want my components to be "flow" from the top left of my frame to the bottom right instead of starting in the center of the screen. GridLayout does this fine, but it re-adjusts the size of my components and I don't like that. I would use GridBagLayout but it is so complicated I wanted to see If it is possible to do what I want with FlowLayout.

like image 274
ubiquibacon Avatar asked Feb 24 '23 10:02

ubiquibacon


1 Answers

You can pass it as parameter to the constructor

new FlowLayout(FlowLayout.LEADING);

Edit: After having the code I recognized that the vertical alignment is your issue. You should switch to another layout to fix this, e.g.:

contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.X_AXIS));
like image 56
Howard Avatar answered May 17 '23 10:05

Howard