BreezySwing
Class GBApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--BreezySwing.GBApplet
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable

public class GBApplet
extends javax.swing.JApplet

The class GBApplet (short for Grid Bag Applet) provides a high-level applet window. The window comes with a built in GridBagLayout. Components are added to the window by specifying their row position, column position, width (in columns), and height (in rows)in the grid.

Events of different types, such as button clicks and list item selections, are handled by implementing the appropriate GBApplet methods in the application.

Unlike GBFrame, GBApplet does not support pull down menus.

Example use of GBApplet:

    // Hello world applet with BreezyGUI.
import java.awt.*; import BreezyGUI.*;
public class HelloWorld extends GBApplet{
// Add a labeled button to the window at row 1, column 1, width 1, height 1. Button clickMe = addButton("Click me", 1, 1, 1, 1);
// Implement the method to handle the button click. public void buttonClicked(Button buttonObj){ messageBox("Hello world!"); } }

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GBApplet()
          Creates a GBApplet.
 
Method Summary
 javax.swing.JButton addButton(java.lang.String text, int row, int col, int width, int height)
          Adds a JButton with the specified name to the specified position, with the specified width and height.
 javax.swing.JCheckBox addCheckBox(java.lang.String text, int row, int col, int width, int height)
          Adds a JCheckBox to the specified position, with the specified width and height.
 javax.swing.JComboBox addComboBox(int row, int col, int width, int height)
          Adds a JComboBox (pull down list) to the specified position, with the specified width and height.
 DoubleField addDoubleField(double num, int row, int col, int width, int height)
          Adds a DoubleField containing the specified number to the specified position, with the specified width and height.
 IntegerField addIntegerField(int num, int row, int col, int width, int height)
          Adds an IntegerField containing the specified integer to the specified position, with the specified width and height.
 javax.swing.JLabel addLabel(java.lang.String text, int row, int col, int width, int height)
          Adds a label with the specified name to the specified position, with the specified width and height.
 javax.swing.JList addList(int row, int col, int width, int height)
          Adds a JList (a scrolling list) to the specified position, with the specified width and height.
 GBPanel addPanel(GBPanel panel, int row, int col, int width, int height)
          Adds a GBPanel to the specified position, with the specified width and height.
 javax.swing.JRadioButton addRadioButton(java.lang.String text, int row, int col, int width, int height)
          Adds a JRadioButton to the specified position, with the specified width and height.
 javax.swing.JTextArea addTextArea(java.lang.String text, int row, int col, int width, int height)
          Adds a JTextArea containing the specified string to the specified position, with the specified width and height.
 javax.swing.JTextField addTextField(java.lang.String text, int row, int col, int width, int height)
          Adds a JTextField containing the specified string to the specified position, with the specified width and height.
 void buttonClicked(javax.swing.JButton buttonObj)
          The application must implement this method in order to handle button clicks.
 void listDoubleClicked(javax.swing.JList listObj, java.lang.String itemClicked)
          The application must implement this method in order to handle a double click on an item in a scrolling list.
 void listItemSelected(javax.swing.JList listObj)
          The application must implement this method in order to handle a selection (single click) on an item in a scrolling list.
 void messageBox(double num)
          Pops up a message box containing the number and an OK button.
 void messageBox(double num, int width, int height)
           
 void messageBox(java.lang.Object msg)
          Pops up a message box containing the string representation of the object and an OK button.
 void messageBox(java.lang.Object msg, int width, int height)
           
 void messageBox(java.lang.String msg)
          Pops up a message box containing the string and an OK button.
 void messageBox(java.lang.String msg, int width, int height)
           
 void setLookAndFeel(java.lang.String type)
          Allows the application to set the look and feel of the window and all its subcomponents to a platform-specific look and feel.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GBApplet

public GBApplet()
Creates a GBApplet.
Method Detail

messageBox

public void messageBox(double num)
Pops up a message box containing the number and an OK button.

messageBox

public void messageBox(java.lang.String msg)
Pops up a message box containing the string and an OK button.

messageBox

public void messageBox(java.lang.Object msg)
Pops up a message box containing the string representation of the object and an OK button.

messageBox

public void messageBox(double num,
                       int width,
                       int height)

messageBox

public void messageBox(java.lang.String msg,
                       int width,
                       int height)

messageBox

public void messageBox(java.lang.Object msg,
                       int width,
                       int height)

setLookAndFeel

public void setLookAndFeel(java.lang.String type)
Allows the application to set the look and feel of the window and all its subcomponents to a platform-specific look and feel. If no event handling is desired, this method need not be implemented.
Parameters:
type - A String, either "METAL", "MOTIF", or "OTHER"

listItemSelected

public void listItemSelected(javax.swing.JList listObj)
The application must implement this method in order to handle a selection (single click) on an item in a scrolling list. If no event handling is desired, this method need not be implemented.
Parameters:
listObj - The JList in which the selection occurred.

buttonClicked

public void buttonClicked(javax.swing.JButton buttonObj)
The application must implement this method in order to handle button clicks. If no buttons are added to the window, this method need not be implemented.
Parameters:
buttonObj - The JButton in which the click occurred. Example:
    // Add the buttons to the window.
    JButton okButton = addButton("OK", 1, 1, 1, 1);
    JButton cancelButton = addButton("Cancel", 1, 2, 1, 1);
    // Handle the button selection.
    public void buttonClicked(JButton buttonObj){
       if (buttonObj == okButton)
          messageBox("OK selected");
       else
          messageBox("Cancel selected");
    }
 

listDoubleClicked

public void listDoubleClicked(javax.swing.JList listObj,
                              java.lang.String itemClicked)
The application must implement this method in order to handle a double click on an item in a scrolling list. If no double click is anticipated, this method need not be implemented.
Parameters:
listObj - The JList in which the double click occurred.
itemClicked - The string selected by the double click.

addLabel

public javax.swing.JLabel addLabel(java.lang.String text,
                                   int row,
                                   int col,
                                   int width,
                                   int height)
Adds a label with the specified name to the specified position, with the specified width and height.
Parameters:
text - The name of the label.
row - The beginning row (starting from 1) of the window's grid in which the label is displayed.
col - The beginning column (starting from 1) of the window's grid in which the label is displayed.
width - The number of columns of the window's grid occuppied by the label.
height - The number of rows of the window's grid occuppied by the label.
Returns:
the JLabel

addButton

public javax.swing.JButton addButton(java.lang.String text,
                                     int row,
                                     int col,
                                     int width,
                                     int height)
Adds a JButton with the specified name to the specified position, with the specified width and height.
Parameters:
text - The name of the Button.
row - The beginning row (starting from 1) of the window's grid in which the Button is displayed.
col - The beginning column (starting from 1) of the window's grid in which the Button is displayed.
width - The number of columns of the window's grid occuppied by the Button.
height - The number of rows of the window's grid occuppied by the Button.
Returns:
the button. Example:
    JButton okButton = addButton("OK", 1, 1, 1, 1);
    // Adds a button at position row 1, column 1,
    // with a width of 1 column and a height of one row.
 

addTextField

public javax.swing.JTextField addTextField(java.lang.String text,
                                           int row,
                                           int col,
                                           int width,
                                           int height)
Adds a JTextField containing the specified string to the specified position, with the specified width and height.
Parameters:
text - The string to be displayed initially.
row - The beginning row (starting from 1) of the window's grid in which the JTextField is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JTextField is displayed.
width - The number of columns of the window's grid occuppied by the JTextField.
height - The number of rows of the window's grid occuppied by the JTextField.
Returns:
the JTextField.

addTextArea

public javax.swing.JTextArea addTextArea(java.lang.String text,
                                         int row,
                                         int col,
                                         int width,
                                         int height)
Adds a JTextArea containing the specified string to the specified position, with the specified width and height.
Parameters:
text - The string to be displayed initially.
row - The beginning row (starting from 1) of the window's grid in which the JTextArea is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JTextArea is displayed.
width - The number of columns of the window's grid occuppied by the JTextArea.
height - The number of rows of the window's grid occuppied by the JTextArea.
Returns:
the TextArea.

addList

public javax.swing.JList addList(int row,
                                 int col,
                                 int width,
                                 int height)
Adds a JList (a scrolling list) to the specified position, with the specified width and height.
Parameters:
row - The beginning row (starting from 1) of the window's grid in which the JList is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JList is displayed.
width - The number of columns of the window's grid occuppied by the JList.
height - The number of rows of the window's grid occuppied by the JList.
Returns:
the JList

addComboBox

public javax.swing.JComboBox addComboBox(int row,
                                         int col,
                                         int width,
                                         int height)
Adds a JComboBox (pull down list) to the specified position, with the specified width and height.
Parameters:
row - The beginning row (starting from 1) of the window's grid in which the JComboBox is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JComboBox is displayed.
width - The number of columns of the window's grid occuppied by the JComboBox.
height - The number of rows of the window's grid occuppied by the JComboBox.
Returns:
the JComboBox.

addIntegerField

public IntegerField addIntegerField(int num,
                                    int row,
                                    int col,
                                    int width,
                                    int height)
Adds an IntegerField containing the specified integer to the specified position, with the specified width and height.
Parameters:
num - The integer to be displayed initially.
row - The beginning row (starting from 1) of the window's grid in which the IntegerField is displayed.
col - The beginning column (starting from 1) of the window's grid in which the IntegerField is displayed.
width - The number of columns of the window's grid occuppied by the IntegerField.
height - The number of rows of the window's grid occuppied by the IntegerField.

addDoubleField

public DoubleField addDoubleField(double num,
                                  int row,
                                  int col,
                                  int width,
                                  int height)
Adds a DoubleField containing the specified number to the specified position, with the specified width and height.
Parameters:
num - The number to be displayed initially.
row - The beginning row (starting from 1) of the window's grid in which the DoubleField is displayed.
col - The beginning column (starting from 1) of the window's grid in which the DoubleField is displayed.
width - The number of columns of the window's grid occuppied by the DoubleField.
height - The number of rows of the window's grid occuppied by the DoubleField.

addCheckBox

public javax.swing.JCheckBox addCheckBox(java.lang.String text,
                                         int row,
                                         int col,
                                         int width,
                                         int height)
Adds a JCheckBox to the specified position, with the specified width and height.
Parameters:
row - The beginning row (starting from 1) of the window's grid in which the JCheckBox is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JCheckBox is displayed.
width - The number of columns of the window's grid occuppied by the JCheckBox.
height - The number of rows of the window's grid occuppied by the JCheckBox.
Returns:
the JCheckBox.

addRadioButton

public javax.swing.JRadioButton addRadioButton(java.lang.String text,
                                               int row,
                                               int col,
                                               int width,
                                               int height)
Adds a JRadioButton to the specified position, with the specified width and height.
Parameters:
row - The beginning row (starting from 1) of the window's grid in which the JRadioButton is displayed.
col - The beginning column (starting from 1) of the window's grid in which the JRadioButton is displayed.
width - The number of columns of the window's grid occuppied by the JRadioButton.
height - The number of rows of the window's grid occuppied by the JRadioButton.
Returns:
the JRadioButton.

addPanel

public GBPanel addPanel(GBPanel panel,
                        int row,
                        int col,
                        int width,
                        int height)
Adds a GBPanel to the specified position, with the specified width and height.
Parameters:
row - The beginning row (starting from 1) of the window's grid in which the GBPanel is displayed.
col - The beginning column (starting from 1) of the window's grid in which the GBPanel is displayed.
width - The number of columns of the window's grid occuppied by the GBPanel.
height - The number of rows of the window's grid occuppied by the GBPanel.
Returns:
the GBPanel.