Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Working Applet
Help and Hints
Source Code
Table of Contents
Online Training
shadowSearchFAQFeedback

RatioLayout

Prerequisites

  • None.
In this exercise, you will write an applet that displays a few components laid out using the RatioLayout layout manager, which allows you to specify the position and size of components relative to the dimensions of the applet or Container.

See the course code for RatioLayout.

Perform the following tasks:

  1. Create an Applet managed by a RatioLayout.
  2. Create a Label ("A RatioLayout Test Applet") and center it 10% down from the top of the applet.
  3. Create a Button ("Button") and center it in both x and y using its preferred size.
  4. Create a TextArea against the left edge 70% down from the top of the applet. Set the size to be 50% of the width and make it span down to the bottom of the applet (%30 of the height).
  5. Create a Button ("OK") 70% across and 70% down using the preferred size.
  6. Create a Button ("BYE") 70% across and 85% down using the preferred size.
The task numbers above are linked to the step-by-step help page. Also available is a complete solution that meets these requirements.

Related Exercises