好贷网好贷款

GridBagLayout 使用方法applet

发布时间:2016-12-4 12:06:34 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"GridBagLayout 使用方法applet",主要涉及到GridBagLayout 使用方法applet方面的内容,对于GridBagLayout 使用方法applet感兴趣的同学可以参考一下。

package com.wanju.chat.ui; import java.awt.*; import java.util.*; import java.applet.Applet; public class GridBagEx1 extends Applet { protected void makebutton(String name,GridBagLayout gridbag,GridBagConstraints c) { Button button = new Button(name); gridbag.setConstraints(button, c); add(button); } public void init() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setFont(new Font("SansSerif", Font.PLAIN, 14)); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; makebutton("Button1", gridbag, c); makebutton("Button2", gridbag, c); makebutton("Button3", gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; // end row makebutton("Button4", gridbag, c); c.weightx = 0.0; // reset to the default makebutton("Button5", gridbag, c); // another row c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last in row makebutton("Button6", gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; // end row makebutton("Button7", gridbag, c); c.gridwidth = 1; // reset to the default c.gridheight = 2; c.weighty = 1.0; makebutton("Button8", gridbag, c); c.weighty = 0.0; // reset to the default c.gridwidth = GridBagConstraints.REMAINDER; // end row c.gridheight = 1; // reset to the default makebutton("Button9", gridbag, c); makebutton("Button10", gridbag, c); setSize(300, 100); } public static void main(String args[]) { Frame f = new Frame("GridBag Layout Example"); GridBagEx1 ex1 = new GridBagEx1(); ex1.init(); f.add("Center", ex1); f.pack(); f.setSize(f.getPreferredSize()); f.setVisible(true); } }

上一篇:Cocos2dx开发必须了解的基本元素
下一篇:java执行exe,并等待exe执行,打印输出

相关文章

相关评论