本文介绍了控制 GridBagConstraints 的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Swing 编程有点陌生,我发现尽管我喜欢 GridBagLayout 的强大功能,但如果您有很多组件,则有很多代码行只是为布局.除了使用可视化编辑器之外,还有哪些好方法可以控制这种情况?

I'm somewhat new to Swing programming, and I find that as much as I love the power of GridBagLayout, if you've got a lot of components, there are lots of lines of code just setting up the constraints for the layout. What are some good ways to keep this under control, besides using a visual editor?

推荐答案

我感受到你的痛苦.我感觉如此之多,以至于我最近完全放弃了 GridBagLayout,转而使用另一个工具 - JGoodies Forms.它的布局代码更简洁,阅读层次更高,总体上比 GridBagLayout 更令人满意.

I feel your pain. I feel it so much, that I have recently abandoned GridBagLayout entirely, in favor of another tool - JGoodies Forms. Its layout code is more concise, reads at a higher level, and is in general much more satisfying to use than GridBagLayout.

它定义了一种定义布局的迷你语言.乍一看,这很神秘,但不要因此而气馁.

It defines a mini-language to define layouts. It's cryptic at first glance, but don't let that discourage you.

如果您能够在您的环境中使用它,我强烈推荐它.

If you are able to use it in your environment, I would highly recommend it.

这篇关于控制 GridBagConstraints 的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:21