Title: Professional Java Programming
ISBN: 186100382x
US Price: $ 59.99
Canadian Price:
C$ 89.95
UK Price: £ 45.99
© Wrox Press Limited, US and UK.

Reviews : Java Books :
Professional Java Programming : Using Layout Managers

maximumLayoutSize()

This method is called by a container when its getMaximumSize() method is called. The layout manager is responsible for calculating the amount of space that the container needs to display all of its components using their maximum sizes. In the case of DividerLayout, it identifies the largest height value from the three components and determines which of the two outer components has a larger width value. That width value is multiplied by 2 since there are two "outer" components that will be assigned identical widths and the result is added to the width of the center component, as shown below:

public Dimension maximumLayoutSize(Container target) {
	Dimension size;
	int width = 0;
	int height = 0;
	if ((westComponent != null) && (westComponent.isVisible())) {
		size = westComponent.getMaximumSize();
		width = Math.max(width, size.width);
		height = Math.max(height, size.height);
	}
	if ((eastComponent != null) && (eastComponent.isVisible())) {
		size = eastComponent.getMaximumSize();
		width = Math.max(width, size.width);
		height = Math.max(height, size.height);
	}
	width *= 2;
	if ((centerComponent != null) && (centerComponent.isVisible())) {
	size = centerComponent.getPreferredSize();
	width += size.width;
	height = Math.max(height, size.height);
	}
	return new Dimension(width, height);
}

getLayoutAlignmentX() and getLayoutAlignmentY()

These methods are provided for layout managers such as BoxLayout that use an alignment value to position the components within the container. Like most layout managers, however, DividerLayout does not use alignment values, so the value returned isn't important, and "dummy" implementations are shown below:

 
public float getLayoutAlignmentX(Container target) {
	return 0.0f;
 }
 
public float getLayoutAlignmentY(Container target) {
	return 0.0f;
}

invalidateLayout()

This method is called to indicate to the layout manager that it should clear any cached information related to the size and position of the container's components. This is only related to information that has been derived by the layout manager itself, and a call to this method does not indicate that constraint information that was explicitly passed to the layout manager should be discarded. For example, if your layout manager performs computations that are slow and complex, it may be worthwhile to cache the results of those computations. Like most layout managers, no action needs to be taken in DividerLayout's implementation of this method:

 
public void invalidateLayout(Container target) {
}

Stop by in one week for the next installment!

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.