我在 JPanel
中有许多 JLabel
(包括 ImageIcon
)。
而这个JPanel
只是GUI上的一个面板;还有很多其他面板。
我想将标签放置到它们的 JPanel
容器上的精确像素坐标。
如何在不使用 GroupLayout
的情况下做到这一点?
最佳答案
参见 Doing Without a Layout Manager (Absolute Positioning)在 Java 教程中。
Creating a container without a layout manager involves the following steps.
- Set the container's layout manager to null by calling
setLayout(null)
.- Call the
Component
class'ssetbounds
method for each of the container's children.- Call the
Component
class'srepaint
method.
关于java - 如何将 JLabels 定位到 Java GUI 上的绝对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/869245/