Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 2 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

GUI Layouts for Swing and SWT: Part 2

At 9:43 AM on Sep 14, 2007, Mikael Grev DeveloperZone Top 100 wrote:

MigLayout is a Layout Manager for Swing and SWT created to replace all current layout managers and introduces a very easy to understand yet powerful syntax that resembles CSS.

This is the second posting in a series that will introduce MigLayout and show how easy it is to use.

If you want to start using MigLayout, just head over to miglayout.com and everything will be there waiting for you, including more examples. Miglayout is 100% free and Open Source (BSD) .

Docking Components, way Beyond BorderLayout

Docking components and panels is a very powerful a easy to understand way to organize a GUI. In Swing you would normally use BorderLayout, however it is very limited since you can only have one panel per side and the overlapping between sides is predetermined and not configurable. MigLayout use simple docking keywords to dock components and panels. The docking component "cuts off" that part of the GUI leaving the rest of the space for the the upcoming components. This is even as flexible as BoxLayout!

The code below produces the panels in the screen shot.

JPanel panel = new JPanel(new MigLayout());
 
panel.add(createLabel("West Panel"),    "dock west");
panel.add(createLabel("North 1 Panel"), "dock north");
panel.add(createLabel("North 2 Panel"), "dock north");
panel.add(createLabel("South Panel"),   "dock south");
panel.add(createLabel("East Panel"),    "dock east");
panel.add(createLabel("Center Panel"),  "grow, push"); // "dock center" from v3.0
 
return panel;

Screen Shot

MigLayout Example02 Screenshot  

The code for creating the panel is not relevant to this example however for completeness I poste it here:

private static JLabel createLabel(String text)
{
   JLabel label = new JLabel(text);
   label.setHorizontalAlignment(JLabel.CENTER);
   label.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 10, 5, 10)));
   return label;
}


Cheers,
Mikael Grev

1 . At 6:45 AM on Sep 15, 2007, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: GUI Layouts for Swing and SWT: Part 2

So in this case, spanning (or overlapping) is defined by the order in which you add the components, right? In your example, the north components span over the east component, but not west. If I added the east component before the north components, the north components would not span over west nor east, right?
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext
2 . At 6:50 AM on Sep 15, 2007, Mikael Grev DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: GUI Layouts for Swing and SWT: Part 2

Hello Romain,

Yes, you are correct. Insertion order matters.

Cheers,
Mikael Grev (grev at miginfocom dot com)
MiG Java Calendar Component, MiG Layout for Swing/SWT (Vote -> JDK)

thread.rss_message