Basic Interface Layout

As you learned yesterday, a graphical user interface designed with Swing is a very fluid thing. Resizing a window can wreak havoc on your interface, as components move to places on a container that you might not have intended.

This fluidity is by necessity. Java is implemented on many different platforms, and there are subtle differences in the way each platform displays things such as buttons, scrollbars, and so on.

With programming languages such as Microsoft Visual Basic, a component's location on a window is precisely defined by its x,y coordinates. Some Java development tools allow similar control over an interface through the use of their own windowing classes.

When using Swing, a programmer gains more control over ...

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.