Java The Complete Reference, Seventh Edition
648 Part II: The Java Library MouseWheelEventdefines methods that give you access to the wheel event. To obtain the number of ro ...
WindowEventis a subclass ofComponentEvent. It defines several constructors. The first is WindowEvent(Windowsrc, inttype) Here,sr ...
fromComponent, such asApplet, can generate events. For example, you can receive key and mouse events from an applet. (You may al ...
Chapter 22: Event Handling 651 The AdjustmentListener Interface This interface defines theadjustmentValueChanged( )method that i ...
The general forms of these methods are shown here: void keyPressed(KeyEventke) void keyReleased(KeyEventke) void keyTyped(KeyEve ...
Chapter 22: Event Handling 653 The WindowListener Interface This interface defines seven methods. ThewindowActivated( )andwindow ...
654 Part II: The Java Library import java.awt.event.*; import java.applet.*; /* <applet code="MouseEvents" width=300 height=1 ...
Chapter 22: Event Handling 655 // Handle button released. public void mouseReleased(MouseEvent me) { // save coordinates mouseX ...
656 Part II: The Java Library Here,mlis a reference to the object receiving mouse events, andmmlis a reference to the object rec ...
Chapter 22: Event Handling 657 repaint(); } // Display keystrokes. public void paint(Graphics g) { g.drawString(msg, X, Y); } } ...
msg += "<F2>"; break; case KeyEvent.VK_F3: msg += "<F3>"; break; case KeyEvent.VK_PAGE_DOWN: msg += "<PgDn>"; ...
Adapter Classes Java provides a special feature, called anadapter class,that can simplify the creation of event handlers in cert ...
<applet code="AdapterDemo" width=300 height=100> </applet> */ public class AdapterDemo extends Applet { public void ...
top-level classes in this program.MousePressedDemoextendsApplet, andMyMouseAdapter extendsMouseAdapter. Theinit( )method ofMouse ...
public void init() { addMouseListener(new MyMouseAdapter()); } class MyMouseAdapter extends MouseAdapter { public void mousePres ...
663 23 Introducing the AWT: Working with Windows, Graphics, and Text T he Abstract Window Toolkit (AWT) was introduced in Chapte ...
NOTEOTE If you have not yet read Chapter 22, please do so now. It provides an overview of event handling, which is used by many ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 665 Class Description Graphics Encapsulates the graphi ...
Although the basic structure of the AWT has been the same since Java 1.0, some of the original methods were deprecated and repla ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 667 components that it contains. It does this through ...
«
30
31
32
33
34
35
36
37
38
39
»
Free download pdf