java - SetLocation(int , int) 不工作
问题描述
为什么setLocation(int, int)
无法设置按钮的位置。我有一个ABC
添加两个的类,JButton
然后JPanel
将此面板添加到,JFrame
但是在设置 JButton 的位置时,按钮是并排添加的,但不是在所需的位置。我认为这是因为Flowloyout
.
ABC(){
jframe = new JFrame();
jframe.setSize(600, 600);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setVisible(true);
start = true;
jbutton1 = new JButton("Button1");
jbutton2 = new JButton("Button2");
jbutton1.setLocation(200, 500);
jbutton2.setLocation(300, 550);
// first window of the application
JPanel jp = new JPanel();
jp.add(jbutton1);
jp.add(jbutton2);
jframe.add(jp);
}
解决方案
推荐阅读
- python - 如何在 Python 中的多个异步进程之间进行同步?
- python - 尝试使用内部数据框计算列表中的值时出现 ValueError
- github - GitHub:如何将我拥有的存储库转移到我拥有的组织并将其保存在我的私人帐户中?
- javascript - 仅在进行条带付款时提交表格
- sql - 在 SQL 中使用带有空部分的 if 语句
- flutter - Flutter:变量中小部件的动态列表
- php - php diff 函数 - 当我得到两个日期之间的差异时的错误
- wso2 - 有没有办法使用 WSO2 每分钟调用一次 REST API?
- azure - 将消息重新排队到 Azure 主题订阅
- java - Java 路径未在 Hadoop 中得到识别