在Netbeans Designer中插入框 [英] Inserting Boxes in Netbeans designer
本文介绍了在Netbeans Designer中插入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在JPanel
上的布局中插入一些分隔符.我有3个按钮,我想在它们之间放一个类似于Box.createRigidArea(new Dimension(10, 0))
的东西. Netbeans 6.9.1似乎没有创建它们的选项-是这样吗?有什么解决方法吗?
I'm trying to insert some spacers into a layout on JPanel
. I've got 3 buttons and I'd like to put something similar to Box.createRigidArea(new Dimension(10, 0))
between them. Netbeans 6.9.1 doesn't seem to have an option to create them - is that true? Is there some workaround?
推荐答案
另一种方法是将JPanel
设置为使用BoxLayout
并修改按钮的添加前"或添加后"代码以包含所需的Component
:
Another approach is to set the JPanel
to use BoxLayout
and modify a button's Pre- or Post-Adding code to include the desired Component
:
this.add(Box.createVerticalStrut(10));
生成的代码如下:
jButton1.setText("jButton1");
this.add(Box.createVerticalStrut(10));
add(jButton1);
this.add(Box.createVerticalStrut(10));
您还需要import javax.swing.Box
.
这篇关于在Netbeans Designer中插入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文