Re: Invocations
Stefan Ram wrote:
Ian Wilson <scobloke2@infotop.co.uk> writes:
this.add( titleLabel,
new GBC( 0,0, 2,1, 0.0,0.0, GBC.WEST, GBC.NONE, 5,5,0,5, 0,0 ));
For readability, one would actually like to have keyword
arguments as in Smalltalk, SQL or VBA. As in
Does SQL have keyword arguments?
In Java one could use either
Or:
GridBagConstraints cons = new GridBagConstraints() {{ // Evil...
gridx = 0; gridy = 0; gridwidth = 2; gridheight = 1; ...
}};
However, your colleagues might want to have words with you if they saw
that...
From 1.5 the constants can be imported with import static. My
preference is to subclass GridBagConstraints with a class that is more
suited as a builder. Also replace the use of int constants with enums. So:
import mypackage.layout.GridBag.Constraints;
import static mypackage.layout.GridBag.Constraints.Anchor.*;
import static mypackage.layout.GridBag.Constraints.Fill.*;
....
Constraints cons = new Constraints()
.gridLocation(0, 0)
.gridSize(2, 1)
.anchor(WEST)
.fill(HORIZONTAL)
.insets(5, 5, 0, 5);
....
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/