📄 driver.java
字号:
import java.awt.Color;import javax.swing.JFrame;/** Author: David D. Riley * Date: Jan, 2005 * The completed caterpillar program (see Figure 3.27) */public class Driver { private JFrame theWindow; private Oval head, frontSegment, midSegment, rearSegment; private Oval face, leftEye, rightEye, mouth, mouthCover; private Rectangle frontLeg, frontFoot, midLeg, midFoot, rearLeg, rearFoot; 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 ); 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); mouth.setBackground(Color.red); face.add(mouth, 0); mouthCover = new Oval(0, 0, 30, 5); mouthCover.setBackground(Color.white); mouth.add(mouthCover, 0); frontSegment = new Oval( 180, 100, 50, 50 ); theWindow.add(frontSegment, 0); theWindow.add(head, 0); frontLeg = new Rectangle(200, 150, 10, 20); theWindow.add(frontLeg, 0); frontFoot = new Rectangle(190, 169, 20, 10); theWindow.add(frontFoot, 0); midSegment = new Oval( 230, 100, 50, 50 ); theWindow.add(midSegment, 0); midLeg = new Rectangle(250, 150, 10, 20); theWindow.add(midLeg, 0); midFoot = new Rectangle(240, 169, 20, 10); theWindow.add(midFoot, 0); rearSegment = new Oval( 280, 100, 50, 50 ); theWindow.add(rearSegment, 0); rearLeg = new Rectangle(300, 150, 10, 20); theWindow.add(rearLeg, 0); rearFoot = new Rectangle(290, 169, 20, 10); theWindow.add(rearFoot, 0); theWindow.repaint(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -