Frames
Home ] Up ] Introduction ] The Swing Package ] [ Frames ] Panes, Text & Fonts ] Colors ] Shapes ] Paint Modes ] Images ]

 

Your First Frame
Sizing a Frame
Positioning a Frame
Exiting a Program
A Centered Frame

 

We are all familiar with the use of the term window to describe a rectangular area on a screen.  Most of these windows have a number of decorations such as:

  • A title bar
  • A border
  • A menu bar
  • A tool bar
  • etc.

Java has a class JWindow, which you might think would be what you'd need to create such a window.  However, Java's JWindow doesn't provide any of these window decorations.

Here's a not-very-useful example of a JWindow:

package swingExamples;

import javax.swing.JWindow;

public class WindowExample extends JWindow
{
  public WindowExample()
  {
    setSize(300, 200);
  }
  
  public static void main(String[] args)
  {
    WindowExample window = new WindowExample();
    window.setVisible(true);
  }
}

which produces the absolutely fascinating output window:

It's actually hard to see the window at all, because of the lack of any kind of "decorations", so I added a border to the above image; the border is not part of the window -- it's just a guide to your seeing it.  

Instead, to create a window of your own, in Java, you have to use a class JFrame (not JWindow).  The result is called a frame in Java.

Here's where we start to learn how to create frames...

 

This page was last modified on 02 October, 2007