• Print  |
  • Feedback  |

FOCUS AREAS

Developer Resources

Products

Technologies

API Reference

SAS AppDev Studio 3.0 Developer's Site

Registering Layout Managers


Table of Contents

Introduction
Design Model
Required Classes
Example Layout Manager

Introduction

Layout managers in Java are used by container objects to manage the location of the child components within the real estate of the container. Layout managers are objects that do all the work for the containers. These objects, however, were designed in the early days of Java and thus do not conform to the JavaBeans specification. Specifying which layout managers will be used and how they will work is, therefore, problematic.

Within the IDE we will have to find out from the user which layout manager is to be used and then how to layout each component within the container. Since this process requires some up front work on the part of the developer, we will also need a way to register layout managers with the IDE so that the up front work can be saved. The Layout Manager Dialog is used to select the layout manager that the container will use to layout components. The Constraints Editor Dialog is used to specify the constraints for each contained component.

Design Model

Overview

The programmer needs to be able to provide as much information as possible to allow us to correctly generate code that will create and use the layout managers. In addition, the programmer should have as much information as is possible at his disposal to make it easy to connect layout managers to containers and components to the layout managers. Complex layout managers such as the GridbagLayout make this hard by requiring a constraint object that is a collection of arbitrary numeric or character fields. Many layout managers also hide the information that is required to manage the layout managers. The ease with which complex constraints can be specified relies on the amount of information that was supplied when the layout manager was registered. If this information is left out then the programmer will have a hard time adding complex constraints.

Registration of a layout manager is a two step process. The first step involves the creation of helper classes. These classes provide customizers for the layout managers and the constraints that these managers use. In addition information is provided to webAF to allow it to generate code that reflects the layout managers and the constraints.

The programmer will use the information supplied when the layout manager was registered to, first, select a layout manager and, second, to specify the constraints for each contained component. To select a layout manager, the programmer will be presented with a list of all registered layout managers. To modify the constraints on a component, the programmer will be presented with a constraint customizer to edit the constraint variables and their possible values.

Required Classes

The programmer will have to provide classes that implement the following interfaces. Note that these are design time only classes and can not ship with an applet or application. The interfaces are com.sas.ide.beans.LayoutInfo, com.sas.ide.beans.LayoutCustomizer, com.sas.ide.beans.ConstraintCustomizerInterface, and com.sas.ide.beans.LayoutConstructorInfo.

Example Layout Classes

What follows are an example third party layout manager and the classes that are required to register the layout manager with webAF.