The Awt supports the following types of controls:o Labelso Push buttonso Check boxeso Choice listo Listso Scroll baro Text editing Labels: A label is an object of type Label, and it contains a string, which it displays. Labels are... Continue Reading →
The AWT supports many graphics methods. All graphics are drawn relative to a window. This can be the main window of an applet, a child window of an applet, or a stand-alone application window. A graphics context is encapsulated... Continue Reading →
After the applet, the type of window we will most often create is derived from Frame. We will use it to create child windows within applets, and top-level or child windows for stand-alone application. Two of frame’s constructors... Continue Reading →
The AWT classes are contained in the java.awtpackage. It is one of the Java’s largest packages. Some of the common AWT classes are as follows: Class Description AWTEvent Encapsulates AWT events. AWTEventMulticaster Dispatches events to multiple listeners.... Continue Reading →
Java provides the concept of inner classes that is the classes defined within another classes, or even within an expression. For understanding the benefits provided by inner classes, consider the applet shown below:import java.awt.event.*;import java.applet.*;import java.awt.*;public... Continue Reading →
Event adapters facilitate implementing listener interfaces. Many event listener interfaces have more than one event listener methods. For such interfaces, Java technology defines adapter classes. These have empty implementation of all the event listener methods defined in the... Continue Reading →
Listeners are created by using one or more of the interfaces defined by the java.awt.event package. Example:import java.awt.event.*;import java.applet.*;import java.awt.*;public class MyKeyApplet extends Applet implements KeyListener{ String msg=""; int x=10,y=40; public void init() { addKeyListener(this); } public void paint(Graphics g) { g.drawString(msg,x,y); } public void keyPressed(KeyEvent e) { ... Continue Reading →
Listeners are created by using one or more of the interfaces defined by the java.awt.event package. Example:import java.awt.event.*;import java.applet.*;import java.awt.*;public class MyEventApplet extends Applet implements MouseListener, MouseMotionListener{ String msg=""; int x,y; public void init() { x=y=0; addMouseListener(this); addMouseMotionListener(this); } public void paint(Graphics g) { g.drawString(msg,x,y); } public void... Continue Reading →
Listeners are created by using one or more of the interfaces defined by the java.awt.event package. When an event occurs, the event source invokes the appropriate method defined by the listener and provides an event object as its... Continue Reading →