All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class rebelsky.io.NewSimpleGUI

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Frame
                                   |
                                   +----rebelsky.io.NewSimpleGUI

public class NewSimpleGUI
extends Frame
implements WindowListener, KeyListener
A simple (but growing) and extendible interactive graphical interface designed for novice Java programmers. It is recommended that you subclass this class when you build your first GUI programs. To make your program work, you'll need to override the paintStuff method, the handleKey method, and possibly the setCaption method. You should also call the setTitle() method that NewSimpleGUI inherits from Frame. You may also override any of the methods described in Java's WindowListener and KeyListener interfaces.

Your main() should construct a new object in your class and then call the begin() method for that object.

See Circles for a sample use of this class.

Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.

Version:
1.1 of February 1998
Author:
Samuel A. Rebelsky

Constructor Index

o NewSimpleGUI()
Create a new window with a default title.

Method Index

o begin()
Run the GUI.
o handleKey(char)
Deal with the user pressing a key on the keyboard.
o keyPressed(KeyEvent)
Handle the user pressing a key.
o keyReleased(KeyEvent)
Handle the user releasing a key.
o keyTyped(KeyEvent)
Handle the user typing a key.
o main(String[])
Start the GUI.
o paint(Graphics)
Paint stuff on the screen.
o paintStuff(Graphics)
Paint stuff on the screen.
o setCaption(String)
Set the caption.
o windowActivated(WindowEvent)
Handle the window becoming active.
o windowClosed(WindowEvent)
Handle the window finishing closing.
o windowClosing(WindowEvent)
Handle the window starting to close.
o windowDeactivated(WindowEvent)
Handle the window becoming inactive.
o windowDeiconified(WindowEvent)
Handle the window becoming uniconified.
o windowIconified(WindowEvent)
Handle the window becoming iconified.
o windowOpened(WindowEvent)
Handle the window being opened.

Constructors

o NewSimpleGUI
 public NewSimpleGUI()
Create a new window with a default title.

Methods

o begin
 public final void begin()
Run the GUI.

o setCaption
 public void setCaption(String caption)
Set the caption.

o handleKey
 public void handleKey(char key)
Deal with the user pressing a key on the keyboard. Quits if the user presses a q. This method should be overriden. If the user doesn't press a key you care about, you may want to to call super.handleKey(key).

o paintStuff
 public void paintStuff(Graphics g)
Paint stuff on the screen. Right now, just prints some sample text. This method should be overriden.

o paint
 public void paint(Graphics g)
Paint stuff on the screen.

Overrides:
paint in class Container
o keyPressed
 public void keyPressed(KeyEvent e)
Handle the user pressing a key. Right now, does nothing, but is included because this implements KeyListener.

o keyReleased
 public void keyReleased(KeyEvent e)
Handle the user releasing a key. Right now, does nothing, but is included because this implements KeyListener.

o keyTyped
 public void keyTyped(KeyEvent e)
Handle the user typing a key. Uses handleKey() to determine what to do.

o windowActivated
 public void windowActivated(WindowEvent we)
Handle the window becoming active. Right now, does nothing, but is included because this implements KeyListener.

o windowClosed
 public void windowClosed(WindowEvent we)
Handle the window finishing closing. Exits the program, since I don't know how to do anything else.

o windowClosing
 public void windowClosing(WindowEvent we)
Handle the window starting to close. Gets rid of the window.

o windowDeactivated
 public void windowDeactivated(WindowEvent we)
Handle the window becoming inactive. Right now, does nothing, but is included because this implements KeyListener.

o windowDeiconified
 public void windowDeiconified(WindowEvent we)
Handle the window becoming uniconified. Right now, does nothing, but is included because this implements KeyListener.

o windowIconified
 public void windowIconified(WindowEvent we)
Handle the window becoming iconified. Right now, does nothing, but is included because this implements KeyListener.

o windowOpened
 public void windowOpened(WindowEvent we)
Handle the window being opened. Right now, does nothing, but is included because this implements KeyListener.

o main
 public static void main(String args[])
Start the GUI.


All Packages  Class Hierarchy  This Package  Previous  Next  Index