【问题标题】:Any alternatives to the componentResized method in ComponentAdapterComponentAdapter 中 componentResized 方法的任何替代方法
【发布时间】:2013-01-06 02:58:54
【问题描述】:

当我实现下面的代码时,只有当用户在调整框架大小后释放鼠标时才会调用该方法。我想要一个在用户调整框架大小时连续调用的方法。我能做些什么呢?

frame.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent comp) {
        System.out.println("Resized");
        }
      });

【问题讨论】:

  • 1) 为什么? 2) 为了尽快获得更好的帮助,请发帖SSCCE
  • 为什么?因为我的框架包含一个 JScrollPane。我让 JScrollPane 的大小与框架的大小成正比,使用上面的代码看起来很不稳定。
  • @JoelA.Christophel 这是布局管理器的职责……
  • 是的,我想。但我真的不知道我会这样做。

标签: java swing events jframe componentlistener


【解决方案1】:
//frame.addComponentListener(...
frame.getContentPane().addComponentListener(...

【讨论】:

  • Happy 100。要格式化代码,请选择示例并单击消息发布/编辑表单上的{} 按钮。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 2012-09-25
  • 1970-01-01
相关资源
最近更新 更多