开发者

Inserting Boxes in Netbeans designer

开发者 https://www.devze.com 2023-01-14 06:21 出处:网络
I\'m trying to insert som开发者_如何学JAVAe 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. Netbe

I'm trying to insert som开发者_如何学JAVAe 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?


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));

The generated code will look like this:

jButton1.setText("jButton1");
this.add(Box.createVerticalStrut(10));
add(jButton1);
this.add(Box.createVerticalStrut(10));

You'll also need to import javax.swing.Box.


Simple work around would be to add a JPanel with a custom preferred size.

0

精彩评论

暂无评论...
验证码 换一张
取 消