⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridbaglayoutexample.java

📁 java 布局程序
💻 JAVA
字号:
/*
 * Created on 2004-8-9
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
import java.awt.*;
import java.applet.*;
public class GridBagLayoutExample extends Applet{
	Label txt=new Label("null");
	Button bnorth=new Button("North");
	Button bsouth=new Button("South");
	Button beast=new Button("East");
	Button bwest=new Button("West");
	public void init(){
		GridBagLayout gridbag=new GridBagLayout();
		this.setLayout(gridbag);
		GridBagConstraints c=new GridBagConstraints();
		c.fill=GridBagConstraints.BOTH;
		c.weighty=1;//每行分配到相同的垂直空间
		c.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(bnorth,c);
		add(bnorth);
		c.weightx=1;
		c.weighty =0;
		c.gridwidth=1;
		gridbag.setConstraints(bsouth,c);
		add(bsouth);
		c.weightx=0.5;
		c.gridheight=2;
		gridbag.setConstraints(beast,c);
		add(beast);
		c.gridwidth=GridBagConstraints.REMAINDER;
		gridbag.setConstraints(bwest,c);
		add(bwest);
		c.gridwidth=1;
		c.gridheight=5;
		gridbag.setConstraints(txt,c);
		add(txt);
	}
	public static void main(String[] args) {
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -