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
我花了很多时间试图找出为什么按钮没有出现,但我没有找到原因,有人能帮我解决这个问题吗?
发布于 2013-06-02 03:32:23
只是从我的头顶思考,但这段代码将为您工作。看起来你没有正确地添加按钮;至少从我的角度来看是这样。下面的代码将为您工作。
public class ButtonFrame extends JFrame
{
private JButton plainJButton;
}
public ButtonFrame() {
plainJButton = new JButton( "Plain Button" );
add( plainJButton );
}https://stackoverflow.com/questions/16876377
复制相似问题