0

How can I globally compress Matisse-generated GroupLayout and perhaps other gap spacings to make Swing dialogs generated with Matisse and GroupLayout more compact?

I have used Matisse to re-implement in Java Swing some large dialogs originally developed for Windows in Visual Basic's GUI builder.

The results in the Swing Windows L&F are very similar to native (of a certain age), except more "spread out." At lower res they leak off the screen. This is a real problem for the app.

Measuring shows all the gaps proportionally bigger than the Windows defaults. (The way Swing scales for different resolutions is not helping either.) This includes ContainerGaps emitted by Matisse and L&F-controlled gaps between GUI components.

I have looked at GroupLayout documents and the Matisse documentation I can find. I've looked at L&F parameters and the ContainerGap and related classes in the GroupLayout source. Nothing is taking me where I need to go.

All insight appreciated.

Gene
  • 42,664
  • 4
  • 51
  • 82

1 Answers1

3

There are too many ways this could be wrong and no single point of adjustment that will fix it. The Visual Basic version surely looks good on its single target platform. By design, Swing relies on pack(), which "Causes this Window to be sized to fit the preferred size and layouts of its subcomponents." The preferred size may vary by platform, as shown in this nested layout example. Instead, study available layouts and use the GUI designer in a focused way, as suggested here.

There's no easy way to fix layout problems in the GUI designer without understanding Swing layouts; happily, the GUI designer is an excellent way to study the effects of various Swing layouts.

Community
  • 1
  • 1
trashgod
  • 196,350
  • 25
  • 213
  • 918
  • Thanks. But Windows is not a single target platform. Its dialogs are quite usable across a gigantic array of visual form factors. I understand all you say, but ultimately widget spacing is a (hidden) parameter of `pack()`. Or more likely it's spread accross several parameters. I can see the L&F ones in `UIManage`. It looks like the `GroupLayout` gaps must be changed by subclassing, but Swing often has multiple ways to get things done, so I'm asking. Robust layout managers ought to do reasonable things if gaps are all multiplied by a common factor. – Gene Mar 08 '13 at 23:21
  • I use the term _platform_ in the sense that Java is supported on the Windows platform, among others not supported by Visual Basic. The relevant [tutorial](http://docs.oracle.com/javase/tutorial/uiswing/layout/groupExample.html) addresses gaps; you might verify that the designer is generating the desired code. Additional manual examples may be found [here](http://stackoverflow.com/a/8504753/230513) and [here](http://stackoverflow.com/a/14858272/230513). The NetBeans help topic on `GroupLayout` offers a helpful perspective. – trashgod Mar 09 '13 at 02:23