⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
import java.awt.Color;import javax.swing.JFrame;/**	Author: David D. Riley *		Date: Jan, 2005 *   Second prototype for the carterpillar program (Figure 3.26) */public class Driver  {    private  JFrame  theWindow;    private  Oval  head, frontSegment, midSegment, rearSegment;    private  Oval face, leftEye, rightEye, mouth;    private  Rectangle  frontLeg;    public Driver()   {        theWindow = new JFrame( "The Pede" );        theWindow.setBounds(30, 30, 500, 250);        theWindow.setLayout(null);        theWindow.setVisible(true);        head = new Oval( 110, 70, 84, 84 );        theWindow.add(head, 0);        face = new Oval(2, 2, 80, 80);        face.setBackground(Color.white);        head.add(face, 0);        leftEye = new Oval(15, 30, 15, 10);        leftEye. setBackground (Color.blue);        face.add(leftEye, 0);        rightEye = new Oval(50, 30, 15, 10);        rightEye. setBackground (Color.blue);        face.add(rightEye, 0);        mouth = new Oval(25, 50, 30, 10);        face.add(mouth, 0);        mouth. setBackground (Color.red);        frontSegment = new Oval( 180, 100, 50, 50 );        theWindow.add(frontSegment, 0);        frontLeg = new Rectangle(200, 150, 10, 20);        theWindow.add(frontLeg, 0);        midSegment = new Oval( 230, 100, 50, 50 );        theWindow.add(midSegment, 0);        rearSegment = new Oval( 280, 100, 50, 50 );        theWindow.add(rearSegment, 0);        theWindow.repaint();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -