0
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));

(...)

//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

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

4

1 回答 1

-1

只是从我的脑海中思考,但这段代码对你有用。看来您添加的按钮不正确;至少从我的角度来看。下面的代码将为您工作。

public class ButtonFrame extends JFrame
{
    private JButton plainJButton;
}

public ButtonFrame() {
    plainJButton = new JButton( "Plain Button" );
    add( plainJButton );
}
于 2013-06-01T19:32:22.753 回答