In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
JavaSwingFlowLayout streaming layout implementation, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
1. Overview
FlowLayout, streaming layout manager. Arrange the components horizontally, fill one row, and continue to arrange on the next line. The direction of arrangement (left to right or right to left) depends on the container's componentOrientation property (which belongs to Component), and its possible values are as follows:
ComponentOrientation.LEFT_TO_RIGHT (default) ComponentOrientation.RIGHT_TO_LEFT
The alignment of components in the same row (horizontal) is determined by the align property of FlowLayout, whose possible values are as follows:
FlowLayout.LEFT: align left FlowLayout.CENTER: align (default) FlowLayout.RIGHT: align right FlowLayout.LEADING: align to the start edge of the container direction, for example, for left to right direction, align FlowLayout.TRAILING to the left side: align to the end edge of the container direction, for example, align to the right side for the left to right direction.
The construction method of FlowLayout:
/ / default center alignment, horizontal and vertical gaps are 5 units FlowLayout () / / specify alignment, default horizontal and vertical gaps are 5 units FlowLayout (int align) / / specify how to align them, horizontal and vertical gaps FlowLayout (int align, int hgap, int vgap)
two。 Code example
Package com.xiets.swing;import javax.swing.*;import java.awt.*;public class Main {public static void main (String [] args) {JFrame jf = new JFrame ("Test window"); jf.setSize (200,250); jf.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE); jf.setLocationRelativeTo (null); / / create a content panel that specifies the use of streaming layout
JPanel panel = new JPanel (new FlowLayout ())
JButton btn01 = new JButton ("Button 01")
JButton btn02 = new JButton ("Button 02")
JButton btn03 = new JButton ("Button 03")
JButton btn04 = new JButton ("Button 04")
JButton btn05 = new JButton ("Button 05")
Panel.add (btn01)
Panel.add (btn02)
Panel.add (btn03)
Panel.add (btn04)
Panel.add (btn05)
Jf.setContentPane (panel)
Jf.setVisible (true)
/ / PS: finally, set it to display (draw) before all the added components will be displayed
}
}
After reading the above, have you mastered the implementation of JavaSwingFlowLayout streaming layout? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.