自动调整JLayeredPane的内容大小 [英] Automatic content resizing of JLayeredPane

查看:140
本文介绍了自动调整JLayeredPane的内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个具有JLayeredPane的应用程序,该应用程序会自动按照父级JFrame的大小进行缩放(这是使用BorderLayout作为框架内容窗格上的布局管理器的简单部分).困难的部分是我希望JLayeredPane的内容自动随JLayeredPane调整大小(因此也使JFrame调整大小).

I'm trying to create an app with a JLayeredPane that scales automatically with the size of the parent JFrame (this is the easy part using BorderLayout as layout manager on the frame's content pane). The hard part is the fact that I want the content of the JLayeredPane to automatically resize with the JLayeredPane (and thus the JFrame too).

实际上,我要实现的功能与Netbeans中的可停靠控制台非常相似,就像单击时位于编辑器的顶部",关闭时再次隐藏并停靠在控制台"中一样.状态栏.显然,我也希望调整行为以使其正常工作.最好的方法是什么(如果没有使用JLayeredPane的话)?

In fact the functionality I want to achieve is a lot like the dockable console in Netbeans, that just like comes "on top" of the editor when clicked, and when dismissed hides again and docks into the "console" word in the status bar. Obviously I also want resizing behavior to work correctly. What would be the best way to achieve this (if not with JLayeredPane)?

推荐答案

您将需要使用添加到JLayeredPane的ComponentListener,并使它的内容响应void componentResized(ComponentEvent e)方法.

You'll need to use a ComponentListener added to the JLayeredPane and have its content responds to the void componentResized(ComponentEvent e) method.

这篇关于自动调整JLayeredPane的内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆