Java Netbeans 自动调整文本区域大小
我正在使用 netbeans 7.0.1 构建一个简单的 JFrame 应用程序
我正在使用 gui 生成器放置一个文本区域和几个按钮,
这些按钮位于同一垂直级别,并且右侧按钮在调整窗口大小时向右移动 - 即很好,但我希望文本区域也能这样做 - 即调整大小以适应窗口的相关宽度。
对于我的一生,我看不到这是如何完成的 - 我环顾四周,我可以找到手工编码应用程序的代码,但不能找到 netbeans gui 构建器的代码
I am using netbeans 7.0.1 to build a simple JFrame application
I am putting a textarea and a couple of buttons on using the gui builder
the buttons are on the same vertical level and the right hand button shifts right on resize of the window - that is fine but I would like the text area to do the same - i.e. resize to fit the relevant width of the window.
For the life of me I cannot see how this is done - I have looked around and I can find code for a hand coded app but not for netbeans gui builder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新:啊抱歉,没有阅读完整的问题,您真的想用 netbeans 来完成它..:) 好吧,好吧,现在您有了这篇文章如何手工制作! :)
我不会使用 GUI 构建器来完成此任务。使用
FlowLayout
和BorderLayout
:屏幕截图是由以下代码生成的:
Update: Ah sorry, didn't read the full question, you really want to do it with netbeans.. :) Well, well, now you have this post how to do it hand-crafted aswell! :)
I wouldn't use an GUI builder for this task. It is easy to create such layout with
FlowLayout
andBorderLayout
:Screenshot was produced by this code:
这完全取决于您使用的布局。我个人会使用GridBagLayout,可能是因为我习惯了。基本上,您应该遵循以下步骤:
您可以在此处阅读有关 GridBagLayout 的更多信息: http://netbeans.org/kb/docs /java/gbcustomizer-basic.html
学习 GridBagLayout 可能需要几个小时,习惯它可能需要几天,但它值得学习。只是我的2分钱。
It's all about the layout you're using. I would personally use GridBagLayout, probably because I am accustomed to it. Basically, you should follow these steps:
You can read more about GridBagLayout here: http://netbeans.org/kb/docs/java/gbcustomizer-basic.html
Learning GridBagLayout could take a couple of hours, getting used to it could take a couple of days, but it's worth learning. Just my 2 cents.