GridBagLayout与gridwidth和gridheight限制 : 网格布局 « 图形用户界面 « Java

En
Java
1. 图形用户界面
2. 三维图形动画
3. 高级图形
4. 蚂蚁编译
5. Apache类库
6. 统计图
7. 
8. 集合数据结构
9. 数据类型
10. 数据库JDBC
11. 设计模式
12. 开发相关类
13. EJB3
14. 电子邮件
15. 事件
16. 文件输入输出
17. 游戏
18. 泛型
19. GWT
20. Hibernate
21. 本地化
22. J2EE平台
23. 基于J2ME
24. JDK-6
25. JNDI的LDAP
26. JPA
27. JSP技术
28. JSTL
29. 语言基础知识
30. 网络协议
31. PDF格式RTF格式
32. 映射
33. 常规表达式
34. 脚本
35. 安全
36. Servlets
37. Spring
38. Swing组件
39. 图形用户界面
40. SWT-JFace-Eclipse
41. 线程
42. 应用程序
43. Velocity
44. Web服务SOA
45. 可扩展标记语言
Java 教程
Java » 图形用户界面 » 网格布局屏幕截图 
GridBagLayout与gridwidth和gridheight限制
GridBagLayout与gridwidth和gridheight限制
  

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class GridBagWithGridWidthHeight {

  public static void main(String[] args) {
    JFrame f = new JFrame(
        "Demonstrates the use of gridwidth, gridheight constraints");
    JPanel p = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2222);
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridheight = 2// span across 2 rows
    p.add(new JButton("Java"), c);
    c.gridx = 1;
    c.gridheight = 1// set back to 1 row
    c.gridwidth = 2// span across 2 columns
    p.add(new JButton("Source"), c);
    c.gridy = 1;
    c.gridwidth = 1// set back to 1 column
    p.add(new JButton("and"), c);
    c.gridx = 2;
    p.add(new JButton("Support."), c);

    WindowListener wndCloser = new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    };
    f.addWindowListener(wndCloser);

    f.getContentPane().add(p);
    f.setSize(600200);
    f.show();
  }
}


           
         
    
  
Related examples in the same category
1. GridBagLayout与weightxGridBagLayout与weightx
2. GridBagLayout与制约因素GridBagLayout与制约因素
3. 简单gridbag布局简单gridbag布局
4. GridBagLayout的重量限制GridBagLayout的重量限制
5. GridBagLayout与锚限制GridBagLayout与锚限制
6. GridBagLayout窗格GridBagLayout窗格
7. GridBagConstraints 1
8. GridBagConstraints 3
9. GridBagConstraints 2
10. GridBagConstraints.BOTH
11. Create and set a gridbag layout and how to set gridbag constraints
12. 关联gridbag限制
13. 单元格的位置( 1,1 )
14. Setting the Location of a Component in a GridBagLayout
15. 制作GridBagLayout充满容器
16. Getting the Number of Rows and Columns of Cells in a GridBagLayout
17. Setting the Stretchyness of Rows and Columns in a GridBagLayout Using Layout Weights
18. Place a component at (0,1) with a column weight 1 and a row weight of 2
19. 使用填充设置Stretchyness的GridBagLayout
20. 横向拉伸
21. 纵向延伸
22. 拉伸
23. 双向拉伸
24. Setting the Space around a Component Within the Cell of the GridBagLayout Using Insets
25. A GridBagLayout Example: weightx, weighty
26. Positioning a component in the center of other component using GridbagLayout
27. GridBagConstraints 5
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.