我怎样才能prevent从太多我的萎缩组件一个LayoutManager? [英] How can I prevent a LayoutManager from shrinking my components too much?

查看:195
本文介绍了我怎样才能prevent从太多我的萎缩组件一个LayoutManager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能美元,在BorderLayout管理调整萎缩p $ pvent GUI组件?是否有可能设置一个最小尺寸,以便组件不缩水超越它?看来使用的setBounds不与布局管理工作。

How can I prevent GUI components from shrinking on resizing in a BorderLayout Manager? Is it possible to set a minimum size so that components do not shrink beyond it? It seems using setBounds does not work with Layout Managers.

只是一个问题:如果我使用嵌套面板,是否有可能将它们分配固定的位置,并让布局管理器将这些面板内部组件的照顾?我试图prevent GUI组件从走动。

Just one more question: If I used nested panels, is it possible to assign them fixed positions and let the layout manager takes care of the components inside these panels? I'm trying to prevent GUI components from moving around.

推荐答案

不幸的是,最小尺寸,最大尺寸等是否布局管理荣誉达到布局管理器实现。这导致了很多混乱的现象,因为不是所有的布局管理器孝敬他们,BorderLayout的不接受这些限制。

Unfortunately, whether a layout manager honors minimum size, max size, etc is up to the layout manager implementation. This leads to a lot of confusing behavior because not all layout managers honor them, and BorderLayout doesn't honor those constraints.

的BoxLayout会履行这些值。 JComponent.setBounds是使LayoutManager将用来设置一个孩子的界限让你的布局管理器可能会覆盖不管你摆在那里。如果你试图限制一些小怎么能得到我建议设置你的JFrame或JDialog的最小尺寸,然后从使它太小导致布局管理器做有趣的事情,prevent人。

BoxLayout will honor those values. JComponent.setBounds is what the LayoutManager will use to set the bounds of a child so your layout manager will probably overwrite whatever you put in there. If you are trying to limit how small something can get I'd suggest setting a minimum size on your JFrame or JDialog then that prevent someone from making it too small causing the layout manager to do funny things.

我对任何人进行Swing的第一个建议是抢TableLayout,花15分钟就能学会它,大部分的布局问题是可以解决的。我不知道这是否适用于你在做什么,但你需要它的布局问题之前它不会很长。 TableLayout允许你指定哪些东西放大或缩小,如果窗口太小,以显示它,然后它不会调整它们的大小超过preferred尺寸更小。

My first suggestion for anyone doing Swing is grab TableLayout, spend 15 minutes to learn it, and most of your layout problems can be solved. I don't know if that applies to what you're doing, but it won't be long before you have a layout problem that requires it. TableLayout allows you to specify which things grow or shrink, and if the window is too small to show it then it doesn't resize them smaller than the preferred size.

http://java.sun.com/products/jfc/tsc /用品/ tablelayout /

我不知道到底是什么你想做提供任何更好的建议。

I'm not sure exactly what your trying to do to offer any better advice.

这篇关于我怎样才能prevent从太多我的萎缩组件一个LayoutManager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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