go to previous page   go to home page   go to next page

Answer:

Yes. Place the two button panels in a top panel. Use vertical layout for the content pane. Add the top panel and the result panel.

Class Box

Layout managers sometimes jam components together in a way that makes the layout look cramped. The class Box can help in this situation. A Box object is a container similar to a panel, but lacking some features. The default layout manager of Box is BoxLayout. Several previous example programs could be rewritten using Box in place of JPanel. This would slightly simplify the code since it would rely on the default BoxLayout manager rather than specifically setting it. Constructors for Box look like this:

public Box(int axis)

  where axis is one of: BoxLayout.X_AXIS, BoxLayout.Y_AXIS, (and a few others)

Useful features of class Box are its methods that create invisible components. These components correspond to rectangular areas of the screen. They are used as spacers to separate the visible components. If you have ever set type you know how useful spacers are in creating an attractive page. To create a fixed-sized invisible component use the method:

Box.createRigidArea( new Dimension( int width, int height ) )

The parameter to createRigidArea()is a Dimension object, which does little more than hold a width and a height.

QUESTION 9:

(Thought Question:) Could width and height be arithmetic expressions?