Complex GridbagLayout

xiaoxiao2021-03-06  40

Today, I finally understood how GridbagLayout is used. Constructor: girdbagLayout () Create a new GridbagLayout Manager. GridbagConstraints () builds a new GridbagConstraints object. GridBagConstraints (int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady) GridBagConstraints create a new object and its parameters of the specified value. Looking at the parameters of this pile, I will be troubled. Let's take a look at the meaning of the parameters: Parameter Description: Gridx, Gridy - Set the location of the component, Gridx is set to GridbagConstraints.Rlative Represents this component to the right of the components . Gridy is set to GridbagConstRAINTS.RELATIVE representing the following components below the previously added components. It is recommended to define the location of Gridx and Gridy to maintain the program later. Gridx = 0, Gridy = 0 is placed in 0 lines 0 columns.

GridWidth, GridHeight - Used to set the unit length and height of the component, the default value is 1. You can use the GridbagConstraints.RemainDER constant to represent this component for this row or the last component of this column, and will occupy all remaining spaces.

转载请注明原文地址:https://www.9cbs.com/read-77839.html

New Post(0)