如何禁用 Netbeans 中的自动组件对齐?

发布于 2024-12-23 00:37:26 字数 111 浏览 1 评论 0原文

有什么方法或插件可以禁用 Netbeans 自动组件对齐吗?当我放置标签时,我的所有组件都会随机放置在面板上,而不是我设置它们的方式。每次我添加一个组件时,窗口都会重新调整大小,或者某些组件也会重新调整大小。

Is there any way or plug-in that disables Netbeans automatic component alignment? When I place a label, all my components got placed randomly on the panel, not how I set them up. Every time I add a component the window gets re-sized or some component does.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

〃温暖了心ぐ 2024-12-30 00:37:26

作为一名 NetBeans 的长期用户(现在已经超过 11 年了……天啊,我老了),并且作为一个在 Swing 中工作超过一半时间的人,我认为我有资格给您以下建议:

< strong>不要使用所见即所得的 UI 编辑器。

除非您制作一个带有按钮和文本字段的简单 UI 供您自己使用,否则您在短期(开发)和长期(可维护性)如果你手动创建您的 UI。如果你事先稍微思考一下,这并不难。

我发现最有用的布局管理器是 BorderLayoutFlowLayoutGridLayout,以及我特别喜欢的 BoxLayout code> (包括方便的 Box 组件)。

虽然我自己没有使用过它,但我听说过关于 MiG 布局管理器 的好消息,它有一个很好的相当开始指南。

如果您对使用任何布局管理器有疑问,而许多教程都没有回答(布局管理器概述以及教程链接),只需将它们发布到 SO 即可。

As a long-time NetBeans user (over 11 years now...geez, I'm getting old) and as someone who's worked exclusively in Swing for over half that time I think I'm qualified to give you the following advice:

Don't use a WYSIWYG UI editor.

Unless your whipping out a simple UI with a button and a text field for your own use you're better off in the short term (development) and the long term (maintainability) if you create your UIs by hand. It's not that hard if you do a little thinking beforehand.

The layout managers I've found to be most useful are BorderLayout, FlowLayout, GridLayout, and my particular favorite, BoxLayout (including the handy Box component).

While I haven't used it myself, I've heard good things about the MiG layout manager, which has a nice quite start guide.

If you have questions on using any of the layout managers that the many tutorials don't answer (overview of layout managers with links to tutorials) , just post them at SO.

蓝海 2024-12-30 00:37:26

选择默认 GroupLayout 以外的布局。更好的是,按照 布局管理器的视觉指南

附录:@Paul 有说服力地反对使用 GUI 编辑器。虽然我倾向于同意,但我看到两个合理的用例:

  • 对于新手:一种尝试不太熟悉的布局的便捷方法。
  • 对于经验丰富的开发人员:一种管理您知道将更改的困难布局的方法,如此处建议的那样

Choose a layout other than the default, GroupLayout. Better, do a few manually to get the idea, as suggested in A Visual Guide to Layout Managers.

Addendum: @Paul argues persuasively against using a GUI editor. While I tend to agree, I see two reasonable use cases:

  • For the novice: a convenient way to experiment with less familiar layouts.
  • For the experienced developer: a way to manage that one difficult layout that you just know will change, as suggested here.
羁〃客ぐ 2024-12-30 00:37:26

Netbeans中,制作 GUI 时要做的第一件事是将 GUI 容器框拖动到所需的正确大小,然后将面板添加到 GUI 容器框的内部并将其拉伸以适合容器盒。您可以将所有标签、文本框和组件拖到此主面板中。

要停止自动对齐,只需右键单击该主面板,然后转到“设置布局”,然后选择“空布局”。

那应该可以解决问题!

当您遇到自动对齐问题时,您可以稍后在项目中执行此操作,而不必在项目开始时执行。

In Netbeans, the first thing you do when making a GUI is drag the GUI container box to the right size you want, then add a panel to the inside of your GUI container box and stretch it out to fit the container box. This main Panel is where you drag all your labels, textBoxes, and components to.

To stop the auto aligning, just right click on that main panel, and go to Set Layout, and choose Null Layout.

That should do the trick!!!

You can do it later on in your project when you run into the auto align problem, it doesn't have to be at the start of your project.

青丝拂面 2024-12-30 00:37:26

我还在 Netbeans 中使用“WYSIWYG UI 编辑器”。在我测试了最后一个答案后,我必须纠正这个问题。如果您将“设置布局”设置为“空布局”,则可能会发生所有组件丢失的情况。更好的方法是将其设置为“自由设计”,但恐惧仍然存在。

I am also working with the "WYSIWYG UI editor" in Netbeans. After i testet the last answer, i have to correct this. If you set "Set Layout" to "Null Layout" it can happen, that all your compnents get lost. Better way is to set it to "Free Design", but the fear still remains.

浮光之海 2024-12-30 00:37:26

在使用 netbeans 设计 GUI 应用程序时,请将 JFrame 的布局设置为“自由设计”。
将面板拖到 JFrame 上并将其布局设置为空布局。
现在您可以自由地设计您的 GUI,没有任何尴尬。

In using netbeans to design your GUI application, set the Layout of the JFrame to Free Design.
Drag a panel onto the JFrame and set it Layout to Null Layout.
Now you can freely design your GUI without any embarrassment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文