鍍金池/ 教程/ Java/ Swing GroupLayout布局類
Swing JRadioButton
Swing Layout布局
Swing JTextField
Swing JLabel
Swing開發(fā)環(huán)境安裝
Swing JComponent類
SWING ActionEvent事件類
Swing JScrollBar
Swing教程首頁
Swing JFileChooser
SWING ContainerEvent事件處理類
Swing AdjustmentListener接口
Swing WindowAdapter類
SWING ComponentListener接口
Swing JMenuBar類
Swing JPanel類及實例
Swing
SWING AdjustmentEvent事件處理
Swing JWindow類及實例
Swing介紹
Swing MouseMotionAdapter類
SWING WindowEvent事件類
Swing ItemListener接口
SWING MouseEvent事件類
Swing JMenu類
SWING KeyEvent事件類
Swing MouseMotionListener接口
Swing JProgressBar
SWING AWTEvent事件類
Swing JRadioButtonMenuItem類及例子
Swing KeyAdapter類
SWING ActionListener接口
Swing LayoutManager接口
SWING MouseMotionEvent事件處理
Swing Component類
Swing Container類
Swing CardLayout布局
Swing MouseAdapter類
Swing JSlider
Swing KeyListener接口
Swing FocusAdapter類
Swing JColorChooser
Swing ImageIcon
Swing JComboBox
Swing GroupLayout布局類
Swing JOptionPane
Swing GridBagLayout布局類
Swing JMenuItem類
Swing MouseListener Interface
Swing事件適配器
SWING ComponentEvent處理類
SWING PaintEvent事件類
Swing FlowLayout布局類
SWING Event事件類
Swing FocusListener接口
Swing控件
Swing JButton
Swing JCheckBox
Swing SpringLayout布局類
Swing容器
Swing事件處理
Swing事件監(jiān)聽器
Swing Menu菜單類
Swing JList
Swing ContainerListener接口
Swing LayoutManager2接口
Swing JFrame類和實例
Swing JTextArea
SWING InputEvent事件類
Swing BorderLayout布局
Swing WindowListener接口
Swing JCheckboxMenuItem類及例子
Swing JSpinner
Swing GridLayout布局類
Swing JPopupMenu類及實例

Swing GroupLayout布局類

GroupLayout類的分層組組件為了放置他們在一個容器。

類聲明

以下是聲明 javax.swing.GroupLayout類:

public class GroupLayout
   extends Object
      implements LayoutManager2

字段域

以下是javax.swing.GroupLayout類的字段域:

  • static int DEFAULT_SIZE -- 表示組件或間隙的大小應該用于特定的范圍值。

  • static int PREFERRED_SIZE -- 表示組件或間隙的首選大小應該用于特定的范圍值。

類構造函數(shù)

S.N. 構造函數(shù) & 描述
1 GroupLayout(Container host) 
Creates a GroupLayout for the specified Container.

類方法

S.N. 方法 & 描述
1 void addLayoutComponent(Component component, Object constraints) 
Notification that a Component has been added to the parent container.
2 void addLayoutComponent(String name, Component component) 
Notification that a Component has been added to the parent container.
3 GroupLayout.ParallelGroup createBaselineGroup(boolean resizable, boolean anchorBaselineToTop) 
Creates and returns a ParallelGroup that aligns it's elements along the baseline.
4 GroupLayout.ParallelGroup createParallelGroup() 
Creates and returns a ParallelGroup with an alignment of Alignment.LEADING.
5 GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment) 
Creates and returns a ParallelGroup with the specified alignment.
6 GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment, boolean resizable) 
Creates and returns a ParallelGroup with the specified alignment and resize behavior.
7 GroupLayout.SequentialGroup createSequentialGroup() 
Creates and returns a SequentialGroup.
8 boolean getAutoCreateContainerGaps() 
Returns true if gaps between the container and components that border the container are automatically created.
9 boolean getAutoCreateGaps() 
Returns true if gaps between components are automatically created.
10 boolean getHonorsVisibility() 
Returns whether component visiblity is considered when sizing and positioning components.
11 float getLayoutAlignmentX(Container parent) 
Returns the alignment along the x axis.
12 float getLayoutAlignmentY(Container parent) 
Returns the alignment along the y axis.
13 LayoutStyle getLayoutStyle() 
Returns the LayoutStyle used for calculating the preferred gap between components.
14 void invalidateLayout(Container parent) 
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
15 void layoutContainer(Container parent) 
Lays out the specified container.
16 void linkSize(Component... components) 
Forces the specified components to have the same size regardless of their preferred, minimum or maximum sizes.
17 void linkSize(int axis, Component... components) 
Forces the specified components to have the same size along the specified axis regardless of their preferred, minimum or maximum sizes.
18 Dimension maximumLayoutSize(Container parent) 
Returns the maximum size for the specified container.
19 Dimension minimumLayoutSize(Container parent) 
Returns the minimum size for the specified container.
20 Dimension preferredLayoutSize(Container parent) 
Returns the preferred size for the specified container.
21 void removeLayoutComponent(Component component) 
Notification that a Component has been removed from the parent container.
22 void replace(Component existingComponent, Component newComponent) 
Replaces an existing component with a new one.
23 void setAutoCreateContainerGaps(boolean autoCreateContainerPadding) 
Sets whether a gap between the container and components that touch the border of the container should automatically be created.
24 void setAutoCreateGaps(boolean autoCreatePadding) 
Sets whether a gap between components should automatically be created.
25 void setHonorsVisibility(boolean honorsVisibility) 
Sets whether component visiblity is considered when sizing and positioning components.
26 void setHonorsVisibility(Component component, Boolean honorsVisibility) 
Sets whether the component's visiblity is considered for sizing and positioning.
27 void setHorizontalGroup(GroupLayout.Group group) 
Sets the Group that positions and sizes components along the horizontal axis.
28 void setLayoutStyle(LayoutStyle layoutStyle) 
Sets the LayoutStyle used to calculate the preferred gaps between components.
29 void setVerticalGroup(GroupLayout.Group group) 
Sets the Group that positions and sizes components along the vertical axis.
30 String toString() 
Returns a string representation of this GroupLayout.

方法繼承

這個類從以下類繼承的方法:

  • java.lang.Object

GroupLayout 實例

選擇使用任何編輯器創(chuàng)建以下java程序在 D:/ > SWING > com > yiibai > gui >

SwingLayoutDemo.java
package com.yiibai.gui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SwingLayoutDemo {
   private JFrame mainFrame;
   private JLabel headerLabel;
   private JLabel statusLabel;
   private JPanel controlPanel;
   private JLabel msglabel;

   public SwingLayoutDemo(){
      prepareGUI();
   }

   public static void main(String[] args){
      SwingLayoutDemo swingLayoutDemo = new SwingLayoutDemo();  
      swingLayoutDemo.showGroupLayoutDemo();       
   }
      
   private void prepareGUI(){
      mainFrame = new JFrame("Java SWING Examples");
      mainFrame.setSize(400,400);
      mainFrame.setLayout(new GridLayout(3, 1));

      headerLabel = new JLabel("",JLabel.CENTER );
      statusLabel = new JLabel("",上一篇:Swing事件適配器下一篇:Swing開發(fā)環(huán)境安裝