java调整大小的方法

标签 java swing methods resize jcomponent

您能告诉我在手动调整 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/

相关文章:

java - 创建一个目录,然后在其中创建文件

Java数组索引计数器递归

Java:如何使用 JButton 打开 JOptionPane

algorithm - 运行时的渐近符号

java - 填充 N 叉树 - Java

java - 在 BlackBerry Java 应用程序中解压缩 zip 文件

java - JComponent.setVisible() 在 OS X 上无法成功隐藏分隔符

java - swing 中的对话框问题

javascript - javascript window.stop() 的反义词是什么

java - 如何从具有数组列表的类调用另一个类的方法?