28.12.2012 Views

Core JFC Java Foundation Classes 2nd edition - Read

Core JFC Java Foundation Classes 2nd edition - Read

Core JFC Java Foundation Classes 2nd edition - Read

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1564 Chapter 13 The Pluggable Look-And-Feel<br />

j<br />

Listing 13-5 The <strong>Core</strong> <strong>JFC</strong> look-and-feel button Ul class<br />

(continued)<br />

insets.bottom, insets.right);<br />

emptyBorder = singleEmptyBorder;<br />

} else if (insets.equals(<br />

singleEmptyBorder.getBorderlnsets(c))) {<br />

emptyBorder = singleEmptyBorder;<br />

} else {<br />

emptyBorder = BorderFactory.createEmptyBorder(<br />

insets.top, insets.left,<br />

insets.bottom, insets.right);<br />

}<br />

)<br />

}<br />

// Instance variables<br />

protected Border originalBorder;// The programmer's border<br />

protected boolean borderShown;<br />

// true when the border is visible<br />

protected Border emptyBorder;// Our empty border<br />

protected BasicButtonListener buttonListener;<br />

// Static members<br />

protected static Border SingleEmptyBorder;<br />

protected static final int BORDER_SIZE = 4;<br />

protected static final int TEXT_ICON_GAP = 4;<br />

protected static final int PRESSED_SHIFT_X = 1;<br />

protected static final int PRESSED_SHIFT_Y = 1;<br />

If you scan through the listing, you'll find implementations for only four of<br />

the ten required ButtonUI methods. The other six (update, getPreferredSize,<br />

getMinimumSize, getMaximumSize, contains and get-<br />

DefaultMargin) are inherited directly from BasicButtonUI because<br />

nothing needs to be added to them for our user interface. The code consists<br />

of several distinct pieces, which deal with separate aspects of managing the<br />

button's user interface, listed in Table 13-6.<br />

Table 13-6 Aspects of the C<strong>JFC</strong>ButtonUI Class<br />

Function Description

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!