Java The Complete Reference, Seventh Edition
There are several key methods you will use when working withFramewindows. They are examined here. Setting the Window’s Dimension ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 669 Creating a new frame window from within an applet ...
670 Part II: The Java Library public class AppletFrame extends Applet { Frame f; public void init() { f = new SampleFrame("A Fra ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 671 implements MouseListener, MouseMotionListener { St ...
// Handle mouse dragged. public void mouseDragged(MouseEvent me) { // save coordinates mouseX = me.getX(); mouseY = me.getY(); m ...
// Remove frame window when stopping applet. public void stop() { f.setVisible(false); } // Show frame window when starting appl ...
674 Part II: The Java Library movX = me.getX(); movY = me.getY(); msg = "*"; repaint(); } // Handle mouse moved. public void mou ...
String mousemsg = ""; int mouseX=30, mouseY=30; public AppWindow() { addKeyListener(new MyKeyAdapter(this)); addMouseListener(ne ...
Sample output from this program is shown here: Once created, a frame window takes on a life of its own. Notice thatmain( )ends w ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 677 Drawing Lines Lines are drawn by means of thedrawL ...
To draw a rounded rectangle, usedrawRoundRect( )orfillRoundRect( ), both shown here: void drawRoundRect(inttop, intleft, intwidt ...
void drawOval(inttop, intleft, intwidth, intheight) void fillOval(inttop, intleft, intwidth, intheight) The ellipse is drawn wit ...
The arc is bounded by the rectangle whose upper-left corner is specified bytop,leftand whose width and height are specified bywi ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 681 The polygon’s endpoints are specified by the coord ...
Within the window, a rectangle is drawn around the inner border of the window; within that rectangle, anXis drawn so that it fil ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 683 The first constructor takes three integers that sp ...
684 Part II: The Java Library getRGB( ) To obtain a packed, RGB representation of a color, usegetRGB( ), shown here: int getRGB( ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 685 g.setColor(Color.blue); g.drawOval(190, 10, 90, 30 ...
public void paint(Graphics g) { g.drawLine(0, 0, 100, 100); g.drawLine(0, 100, 100, 0); g.setColor(Color.blue); g.drawLine(40, 2 ...
Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 687 TheFontclass defines these variables: Variable Mea ...
«
31
32
33
34
35
36
37
38
39
40
»
Free download pdf