首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有TableLayout问题

有TableLayout问题
EN

Stack Overflow用户
提问于 2013-06-02 03:22:28
回答 1查看 81关注 0票数 0
代码语言:javascript
复制
public void createWindow2(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setPreferredSize(new Dimension(400, 500));
        setLocationRelativeTo(null);
        setContentPane(new JLabel(new ImageIcon("src\\resources\\registerBg.png")));
        setResizable(false);
        setVisible(false);


        double size[][] = {{TableLayout.FILL,70,10,200,TableLayout.FILL}, //COLUNAS
                {TableLayout.FILL,30,5,30,5,30,5,30,5,30,5,30,82.5,30,82.5}}; //LINHAS
        setLayout(new TableLayout(size));

(...)

代码语言:javascript
复制
//Botoes JPanel
            buts = new JPanel();
            double size2[][] = {{TableLayout.FILL,100,5,100,TableLayout.FILL}, //COLUNAS
                    {TableLayout.FILL}}; //LINHAS
            buts.setLayout(new TableLayout(size2));
            add(buts,"0,4,13,13");
                //Continuar
                continuar = new JButton("Continuar");
                buts.add(continuar,"1,0");
                //Voltar
                voltar =new JButton("Voltar");
                buts.add(voltar,"3,0");

下面是运行该帧的图像

http://oi42.tinypic.com/m83cko.jpg

我花了很多时间试图找出为什么按钮没有出现,但我没有找到原因,有人能帮我解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2013-06-02 03:32:23

只是从我的头顶思考,但这段代码将为您工作。看起来你没有正确地添加按钮;至少从我的角度来看是这样。下面的代码将为您工作。

代码语言:javascript
复制
public class ButtonFrame extends JFrame
{
    private JButton plainJButton;
}

public ButtonFrame() {
    plainJButton = new JButton( "Plain Button" );
    add( plainJButton );
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16876377

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档