标题:GridBagConstraints
只看楼主
chaiyesong
Rank: 2
等 级:论坛游民
威 望:3
帖 子:70
专家分:44
注 册:2014-5-14
结帖率:77.78%
 问题点数:0 回复次数:0 
GridBagConstraints
import javax.swing.*;
import java.awt.*;
public class demo_7
{
    public static void main(String[] args)
    {
        demo_7_1 test=new demo_7_1();
    }
}

class demo_7_1 extends JFrame
{
    GridBagLayout  gridbaglayout=new GridBagLayout();
    GridBagConstraints  gridbagconstraints;
    JPanel jp;
    JButton jbutton1;
    JButton jbutton2;
    JButton jbutton3;
    JButton jbutton4;
    JButton jbutton5;
    public demo_7_1()
    {
        
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setBounds(0,0,400,300);
        jp=new JPanel();
        this.setContentPane(jp);
        gridbagconstraints=new GridBagConstraints();
        gridbagconstraints.gridx=GridBagConstraints.REMAINDER;
        gridbagconstraints.gridy=0;
        // gridbagconstraints.gridwidth=4;//表示该组件为该行中的最后一行
        // gridbagconstraints.gridheight=2;
        jp.setLayout(gridbaglayout);
        jbutton1=new JButton("jbutton1");
        jbutton2=new JButton("jbutton2");
        jbutton3=new JButton("jbutton3");
        jbutton4=new JButton("jbutton4");
        jbutton5=new JButton("jbutton5");
        jp.add(jbutton1);
        jp.add(jbutton2);
        jp.add(jbutton3);
        jp.add(jbutton4);
        jp.add(jbutton5);
        gridbaglayout.setConstraints(jbutton1,gridbagconstraints);
    }
}

这个效果怎么出不来啊 哪位大侠帮忙一下啊
搜索更多相关主题的帖子: public import 
2014-05-14 12:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-431515-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.082250 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved