Java The Complete Reference, Seventh Edition
f.setSize(100, 100); FileDialog fd = new FileDialog(f, "File Dialog"); fd.setVisible(true); } } The output generated by this pro ...
TheeventMaskargument is a bit mask that defines the events to be delivered to this component. TheAWTEventclass definesintconstan ...
750 Part II: The Java Library MyButtonis an inner class that extendsButton. Its constructor usessuperto pass the label of the bu ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 751 import java.awt.event.; import java.applet.; public class Checkbo ...
752 Part II: The Java Library enableEvents(AWTEvent.ITEM_EVENT_MASK); } protected void processItemEvent(ItemEvent ie) { showStat ...
Chapter 24: Using AWT Controls, Layout Managers, and Menus 753 List. It callsenableEvents( )so that both action and item events ...
*/ import java.awt.*; import java.awt.event.*; import java.applet.*; public class ScrollbarDemo2 extends Applet { MyScrollbar my ...
25 Images T his chapter examines the AWT’sImageclass and thejava.awt.imagepackage. Together, they provide support forimaging(the ...
images. These images, when properly created, can be of much higher fidelity as well as more highly compressed than a GIF encodin ...
The first version returns anImageobject that encapsulates the image found at the location specified byurl.The second version ret ...
758 Part II: The Java Library When this applet runs, it starts loadingimgin theinit( )method. Onscreen you can see the image as ...
Here is a simple example of animageUpdate( )method: public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) ...
This flashing is distracting and causes the user to perceive your rendering as slower than it actually is. Use of an offscreen i ...
flicker = true; repaint(); } }); } public void paint(Graphics g) { Graphics screengc = null; if (!flicker) { screengc = g; g = b ...
762 Part II: The Java Library Notice that it is okay to pass in anullas the fourth parameter todrawImage( ). This is the paramet ...
Chapter 25: Images 763 loading). Otherwise, it returnsfalse. You can use thecheckAll( )method to see if all images being tracked ...
if (tracker.checkID(i, true)) { donecount++; loaded += name[i] + " "; } } Dimension d = getSize(); int w = d.width; int h = d.he ...
Chapter 25: Images 765 This example creates a newMediaTrackerin theinit( )method and then adds each of the named images as a tra ...
766 Part II: The Java Library MemoryImageSource MemoryImageSourceis a class that creates a newImagefrom an array of data. It def ...
Chapter 25: Images 767 The data for the newMemoryImageSourceis created in theinit( )method. An array of integers is created to h ...
«
35
36
37
38
39
40
41
42
43
44
»
Free download pdf