frames

frames - CSc 2700: Lecture # 6 Graphic Packages, Windows...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 2700: Lecture # 6 Graphic Packages, Windows and Frames September 16, 2008 1 Abstract Windows Toolkit and Swing Java provides two packages that contain the classes for graphics program- ming: the original Abstract Windows Toolkit (AWT) and the newer Swing package. AWT is the original class library for graphics programming. The AWT widgets use the interface elements of a particular platform. In other words, a button on a Windows machine may not look or behave the same way as a button on a Unix machine or an Apple. The more modern Swing library paints the components on the screen so that the look and feel of a graphical user interface is consistent from platform to platform. Swing does not replace AWT; in fact, Swing uses many AWT classes. Swing, however, does provide new user interface components (buttons, textboxes, checkboxes etc.) which are platform independent. Figure 1 compares Swing and AWT. The AWT classes are in java.awt package and the Swing classes reside in javax.swing package. AWT in java.awt package Swing in javax.swing package Each component is mapped to a corresponding No platform dependent peers. platform-dependent interface called a peer. Code written in java Platform speci±c and prone to All components look the same, platform speci±c bugs. regardless of the platform Components may look di²erent on di²erent Components are all pre±xed with J, platforms. Components have the look of a e.g., JButton, Jcheckbox, JLabel particular platform. Figure 1: AWT and Swing 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Windows and Frames Every GUI utilizes one or more windows. A GUI may or may not have buttons, check boxes , or menus, but windows it must have windows. The Window class extends Container. A Window holds widgets. Window also implements all the methods of parent class Component. A Java Window is what you normally think of as a ”window” but without borders and a title bar. The Frame class, a member of AWT, extends Window. A Frame is a Window that includes a title bar and border. JFrame is a Swing class that extends Frame. See the diagram in Lecture # 1. We will use JFrame in many of the applications we will discuss in the course. We will also use the Swing classes. A JFrame object is a container for other objects such as buttons, labels,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

frames - CSc 2700: Lecture # 6 Graphic Packages, Windows...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online