14.3. The JFrame Component

The JFrame is the Swing equivalent of the AWT Frame and, as in the AWT, the JFrame is a starting point for graphical applications. Similar to JApplet, a JFrame is a heavyweight Swing component and does not inherit from JComponent. JFrame inherits directly from Frame. The main differences between a JFrame and an AWT Frame are these:

  • Components are added to the content pane, not directly to the frame. Changing the layout manager, background color, etc., also applies to the content pane. Access the content pane through getContentPane.

  • JFrames close automatically when you click on the Close button (unlike AWT Frames). However, closing the last JFrame does not result in your program exiting the Java application. So, your ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.