FlowLayout | Java Swing Tutorial for Beginners
In this Java Swing GUI tutorial we will explore the Java Swing FlowLayout layout manager. FlowLayout arranges its components in order from left to right and top to bottom. It is commonly used to arrange a group of Buttons. You can specify the horizontal alignment as well as the horizontal and vertical component gap.
Check out my KZread Channel for more videos:
/ javacodejunkie
Пікірлер: 13
We continue exploring Java Swing Layout Managers. Please like, comment and subscribe!
Fantastic video!!!
Thank you for this video...
@JavaCodeJunkie
2 жыл бұрын
@Kavishka Madhudhan - You are most welcome! 🙏
Greetings from Iran
Question, is there any way to change where the row of components would start? I would like to use flowlayout but I want the row of components to start somewhere lower on my frame. Thanks!
@JavaCodeJunkie
2 жыл бұрын
@AshDeGamer - Sounds like you need a nested layout where, for example, a FlowLayout (along with any added Components) is added to the Bottom area of a BorderLayout. Play around with it and see if you can achieve what you are looking for. Cheers!
I do not understand how I solve that the button does not disappear when I change the size of the frame when it is set to NORTH, how can I make the buttons not disappear, how to do it so that it works as CENTER but in NORTH?
@JavaCodeJunkie
2 жыл бұрын
@philip8989 - That is where an understanding of Swing layout comes in. As the demo program is currently written, you can't accomplish what you want. Except for the most basic programs (like our demo program) most Swing layouts are composed of multiple nested layout managers to accomplish any complex layouts. We are not at the point in our tutorial series where I have discussed any of these concepts, but we will in later videos. in the mean time, if you would like to delve further into Java Swing layout managers on your own, you can check out the following link: docs.oracle.com/javase/tutorial/uiswing/layout/index.html I would be happy to answer any questions you may have. Cheers!
Why "Button " + Integer.toString(i) and not "Button " + i in the loop. 🤔
@KWAMATR0N
11 ай бұрын
In a previous video you had to add each button with a lengthy line of code where as if you place it in a for loop you can add multiple buttons in a shorter line of code. I believe that the button name parameter only takes a string. Which is why int i is converted to a string.
How you chance the symbol
@JavaCodeJunkie
2 жыл бұрын
@Adroaldo Ferreira - The symbol change is a result of the edition of Eclipse combined with the editor font that I am using. The change of the symbol is automatic. Cheers!