您能告诉我在手动调整 JFrame/JDialog 的大小后调用了哪些方法吗?
(在使用鼠标光标调整大小后,框架在屏幕上可见)。我注意到我的 JDialog 无效,尽管我对其调用了 validate()
或 revalidate()
,但在我稍微调整它的大小后,我的框架变得有效。
最佳答案
我认为是java.awt.event.ComponentListener
The listener interface for receiving component events. When the component's size, location, or visibility changes, the relevant method in the listener object is invoked, and the ComponentEvent is passed to it.
例如:
public class MyFrame extends JFrame implements ComponentListener {
@Override
public void componentResized(ComponentEvent e) {
// re compute?
repaint();
}
}
关于java调整大小的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9963332/