Debugging MigLayout

I blogged a few weeks ago about how you can create a menu bar that overrides the NetBeans Platform's menu bar. (Read about it here.) And, in your own menu bar, you can align the components to the right and create a Web-like effect for mousing over the menus. (Read about that here.)

But I learned something else related to all that this week. Here's the problem that started my new "learning moment":

As you can see, there's a small space to the right of "Welcome Guest >>", i.e., the upper part of the menu bar is not correctly aligned with the lower part.

I'm using MigLayout above. So I contacted Mikael Grev from MigLayout to ask him what might be causing the above problem. Then he told me about the "debug" command. OK, so I added "debug" to the MigLayout command, as shown below:

setLayout(new MigLayout("debug, nogrid, align right"));

Now run the app again and I saw this:

Wonderful. Now you can see the bounds of the whole layout and the bounds the components get. I can now see that there's some extra space at the end of the upper part of the menu bar. In this case, the upper part is a JPanel constructed in the Matisse GUI Builder. So I opened that in the IDE:

As you can see, there some extra space at the right side of the panel. So I closed up that space by resizing the panel:

And then I ran the app again, with this result:

Hurray. The space is removed and now everything aligns correctly. Also notice that the space between the upper and lower part is now smaller, because I used "wrap 1" instead of "wrap", so I imagine that the default wrap is bigger than 1 and by using 1 I was able to decrease the difference between the two parts of the menu bar.

Then just remove the "debug" command and everything is exactly as I wanted it:

Thanks a lot Mikael for your support and your great layout manager!

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today