【发布时间】:2013-01-17 21:20:45
【问题描述】:
我正在尝试使用 Eclipse 创建 Java 7 通讯簿,当我测试运行 JFrame 时,JLabels 不可见并且 JButton 重叠。 (按钮会占据整个 JFrame) 例如
add(saveButton);
add(cancelButton);
add(headingLabel);
headingLabel.setVisible(true);
cancelButton.setLocation(200,200);
saveButton.setLocation(400,200);
cancelButton.setSize(200,50);
saveButton.setSize(200,50);
我做错了什么?
【问题讨论】:
-
我们需要看更多的代码,你的布局风格是什么? JFrame是如何定义的?
-
解决方案:了解和使用布局管理器。不要使用绝对定位。这个问题已经在这个网站上被询问和回答了很多次,而且答案没有变化。
标签: java eclipse swing user-interface jbutton