ArithmeticLayoutManager 1.0

ArithmeticLayoutManager is an arithmetic layout manager for Swing/AWT.
ArithmeticLayoutManager is an arithmetic layout manager for Swing/AWT.

The ArithmeticLayoutManager is a layout manager which can be used to specify the bounds of a component as a series of mathematical expressions which are re-evaluated every time the parent is resized.

The expressions consist of simple arithmetics combined with references to fields of other components (the parent and siblings).

ArithmeticLayoutManager was born out of dissatisfaction with existing layout managers. Although some extremely powerful layout managers exist, most of them present the programmer with a horrendous amount of complexity by requiring intricate chains of invocations, an unintuive String syntax, or a complex configuration procedure (or all of the above). As a result most developers simply use the null layout, which decreases the usability of the program. ArithmeticLayoutManager aims combine an intuitive Java/CSS-like syntax with powerful arithmetic expressions.

Lets start by doing a trick that is extremely hard to do in most layout managers:

Container panel = getContentPane();
panel.setLayout(new ArithmeticLayoutManager());

JLabel nameLabel = new JLabel("Name:");
"name = nameLabel; "+
"top = 20; "+
"left = 20; ");

JTextField nameField = new JTextField();
"top = 20; "+
"left = nameLabel.rRight + 20; "+
"right = 20; ");


· Java Runtime Environment

last updated on:
April 15th, 2008, 19:26 GMT
developed by:
Marco Slot
license type:
The Apache License 2.0 
ROOT \ Science and Engineering \ Mathematics


In a hurry? Add it to your Download Basket!

user rating 9



Add your review!