O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The View Classes

Now that we have an overview of what views are and how they fit together, we’ll take a closer look at each of the public view classes, starting with the abstract base class, View.

The View Class

This abstract class represents how a single Element is displayed within a document. It defines properties and behavior common to different types of views. As we showed in Figure 23.2, all other view classes extend from View.

Properties

The View class defines the properties shown in Table 23.2. The attributes property defines the AttributeSet used by the view to render an Element. By default, the Element’s attributes are used. However, view objects should access the attributes through the getAttributes() accessor, to allow view-specific attributes to be added to the Element’s attributes or to allow the attributes to be converted in some way by the view subclasses.

Table 23-2. View Properties

Property

Data Type

get

is

set

bound

Default Value

alignment (indexed)

float

•

   

0.5

attributes

AttributeSet

•

   

from the Element

container

Container

•

   

from parent

document

Document

•

   

from the Element

element

Element

•

   

from constructor

endOffset

int

•

   

from the Element

maximumSpan (indexed)

float

•

   

if resizeWeight==0, preferredSpan, else Integer.MAX_VALUE

minimumSpan (indexed)

float

•

   

if resizeWeight==0, preferredSpan, else 0

parent

View

• ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required