gpt4 book ai didi

java - 忽略设置界限

转载 作者:行者123 更新时间:2023-12-02 07:38:47 25 4
gpt4 key购买 nike

我只是想通过 setBounds 方法放置我的 JButton。但无论这个方法的参数是什么,按钮都位于顶部的中间。

这是我的代码:

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class Panneau_fenetre1A extends JPanel
{
JButton boutonOK = new JButton ("OK");


public Panneau_fenetre1A(int Na)
{
boutonOK.setBounds(300,300,30,30);
add(boutonOK);

}

}

最佳答案

按钮的位置还取决于您当前使用的布局。这是 Vusual Guide to Layout帮助您决定最适合您需求的布局。

关于java - 忽略设置界限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11852510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com