What’s wrong with the Null Layout in Java? [duplicate]

The major problem is the complexities involved in trying to make determination about individual platforms with regards to things like fonts and how pixels may be rendered

Even two systems, running the same OS can generate different output due to different hardware drivers and rendering pipelines.

Much of the API has been abstracted in such away that you should never care that one PC is using a DPI of 120 and using DirectX and another is using a DPI of 92 and using OpenGL.

Layout managers remove the developer from the responsibility of having to calculate the size a component (and its child components) at a particular moment in time as well as calculating the relationship between these components and does it in a standardised way.

The core Swing API has been designed to utilise this API, so when a component changes in some way that would represent a change in the size, all the required containers are notified automatically and the entire hierarchy of components can be adjusted as required.

The basic idea of a layout manager is to describe the relation between components on the same container as well as providing information about how much that container might like to have. This allows you to focus on the user-ability follow of the UI rather then trying to spend time trying to update the UI to meet all various possible combinations of hardware and software.

As a former VB developer (no, I’m not proud if it), I can assure you, the most frustrating part of working with it was trying to develop usable, dynamic UIs that didn’t look crap on the next clients machine.

Of all the aspects of Swing, the layout management is one of the most welcomed – IMHO

Leave a Comment