All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class BreezyGUI.GBFrame

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

public class GBFrame
extends Frame
The class GBFrame (short for Grid Bag Frame) provides a high-level application 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 menu item selections, are handled by implementing the appropriate GBFrame methods in the application.

Example use of GBFrame:
    // Hello world application with BreezyGUI.
import java.awt.*; import BreezyGUI.*;
public class HelloWorld extends GBFrame{
// 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!"); }
// Implement the method that runs when the application is launched. public static void main(String[] args){ Frame frm = new HelloWorld(); frm.setSize(100, 100); frm.setVisible(true); } }


Constructor Index

 o GBFrame()
Creates a GBFrame application window.

Method Index

 o addButton(String, int, int, int, int)
Adds a Button with the specified name to the specified position, with the specified width and height.
 o addCheckbox(String, int, int, int, int)
Adds a CheckBox to the specified position, with the specified width and height.
 o addChoice(int, int, int, int)
Adds a Choice (pull down list) to the specified position, with the specified width and height.
 o addDoubleField(double, int, int, int, int)
Adds a DoubleField containing the specified number to the specified position, with the specified width and height.
 o addIntegerField(int, int, int, int, int)
Adds an IntegerField containing the specified integer to the specified position, with the specified width and height.
 o addLabel(String, int, int, int, int)
Adds a label with the specified name to the specified position, with the specified width and height.
 o addList(int, int, int, int)
Adds a List (a scrolling list) to the specified position, with the specified width and height.
 o addMenuItem(String, String)
Adds an item with the specified name to a menu with the specified name in the window.
 o addTextArea(String, int, int, int, int)
Adds a TextArea containing the specified string to the specified position, with the specified width and height.
 o addTextField(String, int, int, int, int)
Adds a TextField containing the specified string to the specified position, with the specified width and height.
 o buttonClicked(Button)
The application must implement this method in order to handle button clicks.
 o listDoubleClicked(List, String)
The application must implement this method in order to handle a double click on an item in a scrolling list.
 o listItemSelected(List)
The application must implement this method in order to handle a selection (single click) on an item in a scrolling list.
 o menuItemSelected(MenuItem)
The application must implement this method in order to handle menu events.
 o messageBox(double)
Pops up a message box containing the number and an OK button.
 o messageBox(Object)
Pops up a message box containing the string representation of the object and an OK button.
 o messageBox(String)
Pops up a message box containing the string and an OK button.
 o mouseClicked(int, int)
The application must implement this method in order to handle mouse clicks in the window.
 o mouseDragged(int, int)
The application must implement this method in order to handle mouse dragged events in the window.
 o mouseMoved(int, int)
The application must implement this method in order to handle mouse moved events in the window.
 o mousePressed(int, int)
The application must implement this method in order to handle mouse pressed events in the window.
 o mouseReleased(int, int)
The application must implement this method in order to handle mouse released events in the window.
 o pause()
Used with non-GUI applications (tester programs) to pause execution until the user hits the Enter key.

Constructors

 o GBFrame
 public GBFrame()
Creates a GBFrame application window.

Methods

 o pause
 public static void pause()
Used with non-GUI applications (tester programs) to pause execution until the user hits the Enter key. Prevents a "fly-by" disappearance of the terminal window in some environments by pausing execution until the user hits the Enter key. Usage: GBFrame.pause();

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

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

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

 o menuItemSelected
 public void menuItemSelected(MenuItem mi)
The application must implement this method in order to handle menu events. If no menus are added to the window, this method need not be implemented.

Parameters:
mi - The MenuItem in which the selection occurred. Example:
    // Add the menu items to the window.
    MenuItem newFileMI = addMenuItem("File", "New");
    MenuItem openFileMI = addMenuItem("File", "Open");
    MenuItem saveFileMI = addMenuItem("File", "Save");
    // Handle the menu selection.
    public void menuItemSelected(MenuItem mi){
       if (mi == newFileMI)
          messageBox("File/New selected");
       else if (mi == openFileMI)
          messageBox("File/Open selected");
       else
          messageBox("File/Save selected");
    }
 
 o listItemSelected
 public void listItemSelected(List 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 List in which the selection occurred.
 o buttonClicked
 public void buttonClicked(Button 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 Button in which the click occurred. Example:
    // Add the buttons to the window.
    Button okButton = addButton("OK", 1, 1, 1, 1);
    Button cancelButton = addButton("Cancel", 1, 2, 1, 1);
    // Handle the button selection.
    public void buttonClicked(Button buttonObj){
       if (buttonObj == okButton)
          messageBox("OK selected");
       else
          messageBox("Cancel selected");
    }
 
 o listDoubleClicked
 public void listDoubleClicked(List listObj,
                               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 List in which the double click occurred.
itemClicked - The string selected by the double click.
 o mouseClicked
 public void mouseClicked(int x,
                          int y)
The application must implement this method in order to handle mouse clicks in the window. If no event handling is desired, this method need no be implemented.

Parameters:
x - The x coordinate of the mouse in the window.
y - The y coordinate of the mouse in the window.
 o mousePressed
 public void mousePressed(int x,
                          int y)
The application must implement this method in order to handle mouse pressed events in the window. If no event handling is desired, this method need no be implemented.

Parameters:
x - The x coordinate of the mouse in the window.
y - The y coordinate of the mouse in the window.
 o mouseReleased
 public void mouseReleased(int x,
                           int y)
The application must implement this method in order to handle mouse released events in the window. If no event handling is desired, this method need no be implemented.

Parameters:
x - The x coordinate of the mouse in the window.
y - The y coordinate of the mouse in the window.
 o mouseMoved
 public void mouseMoved(int x,
                        int y)
The application must implement this method in order to handle mouse moved events in the window. If no event handling is desired, this method need no be implemented.

Parameters:
x - The x coordinate of the mouse in the window.
y - The y coordinate of the mouse in the window.
 o mouseDragged
 public void mouseDragged(int x,
                          int y)
The application must implement this method in order to handle mouse dragged events in the window. If no event handling is desired, this method need no be implemented.

Parameters:
x - The x coordinate of the mouse in the window.
y - The y coordinate of the mouse in the window.
 o addMenuItem
 public MenuItem addMenuItem(String menuName,
                             String itemName)
Adds an item with the specified name to a menu with the specified name in the window.

Parameters:
menuName - The name of the menu.
item - name The name of the menu item (selection).
Returns:
The MenuItem. Example:
    MenuItem newFileMI = addMenuItem("File", "New");
    MenuItem openFileMI = addMenuItem("File", "Open");
    MenuItem saveFileMI = addMenuItem("File", "Save");
 
 o addLabel
 public Label addLabel(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 Label
 o addButton
 public Button addButton(String text,
                         int row,
                         int col,
                         int width,
                         int height)
Adds a Button 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:
    Button 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.
 
 o addTextField
 public TextField addTextField(String text,
                               int row,
                               int col,
                               int width,
                               int height)
Adds a TextField 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 TextField is displayed.
col - The beginning column (starting from 1) of the window's grid in which the TextField is displayed.
width - The number of columns of the window's grid occuppied by the TextField.
height - The number of rows of the window's grid occuppied by the TextField.
Returns:
the TextField.
 o addTextArea
 public TextArea addTextArea(String text,
                             int row,
                             int col,
                             int width,
                             int height)
Adds a TextArea 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 TextArea is displayed.
col - The beginning column (starting from 1) of the window's grid in which the TextArea is displayed.
width - The number of columns of the window's grid occuppied by the TextArea.
height - The number of rows of the window's grid occuppied by the TextArea.
Returns:
the TextArea.
 o addList
 public List addList(int row,
                     int col,
                     int width,
                     int height)
Adds a List (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 List is displayed.
col - The beginning column (starting from 1) of the window's grid in which the List is displayed.
width - The number of columns of the window's grid occuppied by the List.
height - The number of rows of the window's grid occuppied by the List.
Returns:
the List
 o addChoice
 public Choice addChoice(int row,
                         int col,
                         int width,
                         int height)
Adds a Choice (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 Choice is displayed.
col - The beginning column (starting from 1) of the window's grid in which the Choice is displayed.
width - The number of columns of the window's grid occuppied by the Choice.
height - The number of rows of the window's grid occuppied by the Choice.
Returns:
the Choice.
 o 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.
Returns:
s the IntegerField.
 o 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.
Returns:
s the DoubleField.
 o addCheckbox
 public Checkbox addCheckbox(String text,
                             int row,
                             int col,
                             int width,
                             int height)
Adds a CheckBox 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 CheckBox is displayed.
col - The beginning column (starting from 1) of the window's grid in which the CheckBox is displayed.
width - The number of columns of the window's grid occuppied by the CheckBox.
height - The number of rows of the window's grid occuppied by the CheckBox.
Returns:
the CheckBox.

All Packages  Class Hierarchy  This Package  Previous  Next  Index