Class ExtendsStuff

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--ExtendsStuff

public class ExtendsStuff
extends java.awt.Frame

ExtendsStuff - Show how Java's inheritance capability makes writing seemingly complex/powerful programs easy.

This class is used to introduce the concept of inheritance, building on top of the existing things that are sort-of what you want to do. In the lesson "What's Java?," the Edit-Compile-Execute process was introduced with a simple application that used System.out.println( ) to display a String. This class provides a mechanism to display a String in a pop-up window by invoking the method: printInWindow( ).

Field Summary
static int FONT_SIZE
          Default Font Size for Displaying Strings
static int WINDOW_HEIGHT
          Default Height of Pop-Up Window for Displaying Strings
static int WINDOW_WIDTH
          Default Width of Pop-Up Window for Displaying Strings

Method Summary
 void printInWindow(java.lang.String message)
          Pop up a window and print some text in it.
 void setFontSize(int size)
          Set the height of the font to be used to display a String by invoking printInWindow().
 void setWindowHeight(int height)
          Set the height of the window that will be created to contain a String displayed by invoking printInWindow().
 void setWindowWidth(int width)
          Set the width of the window that will be created to contain a String displayed by invoking printInWindow().

Field Detail

FONT_SIZE

public static final int FONT_SIZE
Default Font Size for Displaying Strings

WINDOW_HEIGHT

public static final int WINDOW_HEIGHT
Default Height of Pop-Up Window for Displaying Strings

WINDOW_WIDTH

public static final int WINDOW_WIDTH
Default Width of Pop-Up Window for Displaying Strings
Method Detail

printInWindow

public void printInWindow(java.lang.String message)
Print some text in a window.

Append the supplied text to a StringBuffer and create a new Label consisting of its contents. The new Label will use the current FontSize, which can be changed via setFontSize() method.

The size of the Frame and the attributes of the "SansSerif" Font (size and style) are also set based on current values of private fields. These fields may be changed via setXxx() invocations.

Parameters:
text - String of text to be displayed in a window.
See Also:
setFontSize(int), setWindowHeight(int), setWindowWidth(int)

setFontSize

public void setFontSize(int size)
Set the height of the font to be used to display a String by invoking printInWindow().
Parameters:
size - Height of the font in points.
See Also:
printInWindow(java.lang.String)

setWindowHeight

public void setWindowHeight(int height)
Set the height of the window that will be created to contain a String displayed by invoking printInWindow().
Parameters:
height - number of pixels on window's Y axis.
See Also:
printInWindow(java.lang.String)

setWindowWidth

public void setWindowWidth(int width)
Set the width of the window that will be created to contain a String displayed by invoking printInWindow().
Parameters:
width - number of pixels on window's X axis.
See Also:
printInWindow(java.lang.String)