开发者

NetBeans should be named "Mexican Jumping Beans"

I have been trying to set up a Ja开发者_JAVA百科va form in NetBeans with 15 - 20 visual components (buttons, textfields, etc.) and I have been using the Free Design layout paradigm on the MAC.

According to what I've read, the Free Design layout gives me various alignment guides, but does not try to force my alignments to specific row and column delimiters. However, I'm finding that when I do this, the width of my form may arbitrarily change, or some of the components I've already placed will move around radically when I make even small adjustments to other component positions.

Is there some way to anchor all these components, once placed, or is there a better layout paradigm that gives me the freedom to place components where I wish to?


IMHO, Matisse works best when you know what you want before you start. It doesn't seem to do so well with iterative changes.

Here are a few rules I follow when using Matisse in freeform mode. They don't make it wonderful, just less painful:

  • Build top-to-bottom and left-to-right. Most jumping happens when you go back an try to insert something.
  • Build it in one pass.
  • When you make progress, save it. There are conditions where Matisse will drop its undo list. Don't count on Ctrl-Z to bail you out. I use a local mercurial repo to track my changes.
  • Keep it small. The more elements, the more likely it is to blow up. Build it out of smaller components. For example, if you have a date field with a button to open a calendar
    • make that a component.
    • Add the component to the palette,
    • use that in the larger component.


Maybe it's time to look into other LayoutManagers, like GridBag or something else that will give you what you want. The built-in choice by NetBeans sounds like a poor one for your needs.

If you choose a null LayoutManager you'll get absolute positioning.

But along with it comes absolute responsibility: No help in repositioning any elements.


I've found Using GroupLayout directly works really well. It can be confusing at first because horizontal and vertical layout are done separately, but once you get used to it it's not that difficult. You can definitely get things to align, and stick together when resizing. It's far better then using nested panels, GridBags, and that kind of thing.

MigLayout might work too, but GroupLayout is included in the JDK.


You may want to look at the absolute layout. It allows you to put the component exactly where you want it, without all the jumping around.


GridBag Layout is my favorite, and specially in Matisse (Netbeans GUI). You have like a wizard to graphically manage all the properties.
Will take you few examples to get things perfect as you want, but when you do, you will never look back.

Take a look at Sun Tutorials GridBag Layout


I strongly, strongly recommend MigLayout (And getting away from GUI layout tools). Any time you think you are saving by using a GUI tool quickly evaporates the second you run into layout manager behavior. Real UI's are coded, not built with drag and drop.

I found that it took me about 3 hours of fiddling to get used to MigLayout - after that break in period, I found it to be incredibly intuitive and powerful.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜