Java Applets: Frames and Panels

  • A frame is a container that is used to display GUI-based Java applications.
  • A frame is displayed as a separate window with its own title bar.
  • It can be repositioned on the screen and re-sized as needed by dragging it with the mouse.
  • It contains small buttons in the corner of the frame that allow the frame to be minimized, maximized, and closed.
  • A frame is defined by the JFrame class.
  • A panel is also a container. However, unlike a frame, it cannot be displayed on its own.
  • A panel must be added to another container for it to be displayed.
  • Generally a panel doesn’t move unless you move the container that it’s in.
  • Its primary role is to help organize the other components in a GUI.
  • A panel is defined by the JPanel class.