L7-JFrame-Applets-OptionalPanel - CSE205 Concepts of Computer Science and Data Structures GUI(Graphical User Interfaces Introduction Taking a user input

L7-JFrame-Applets-OptionalPanel - CSE205 Concepts of...

This preview shows page 1 - 7 out of 15 pages.

CSE205 Concepts of Computer Science and Data Structures
GUI (Graphical User Interfaces) Introduction
Taking a user input using a console (a user might enter an invalid input such as a number out of Range or a string containing non-digit characters): Taking a user input using Applet (a user is forced to choose among 0 through 7):
Making a Java program to generate a GUI is accomplished by using pre-defined classes in packages such as javax.swing and java.awt. Swing is a comprehensive solution to developing graphical use interfaces. There are more than 250 classes.
GUI Class Hierarchy (Swing) Dimension Font FontMetrics Component Graphics Object Color Container Panel Applet Frame Dialog Window JComponent JApplet JFrame JDialog Swing Components in the javax.swing package Lightweight Heavyweight Classes in the java.awt package 1 LayoutManager *
JFrame, JApplet, and JDialog are heavy weight container classes that can be displayed alone and are used to contain other components. JFrame : the container that holds other Swing user-interface components in Java Graphical applications. It can be used in a Java program with a main method (Applications). JApplet : It is a subclass of the Applet class. Applet is defined in java.applet package and JApplet is defined in javax.swing package. You need to create a class that extends JApplet to create a Swing based Java applet. Such class will not contain a main method. Instead it contains applet purpose methods such as init(), start(), stop(), and destroy(). The applet will be displayed with a html file or appletviewer. JDialog/JOptionPane : a popup window or message box generally used as a temporary window to receive information from a user or provide notification that an event has occurred.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture