driver.java
来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 33 行
JAVA
33 行
import java.awt.Color;import javax.swing.JFrame;/** Author: David D. Riley * Date: Jan, 2005 * An erroneous prototype of the caterpillar program (Figure 3.28) */ // This prototype contains two logic errors. public class Driver { private JFrame theWindow; private Oval head, frontSegment, midSegment, rearSegment; public Driver() { theWindow = new JFrame( "The Pede" ); theWindow.setBounds(10, 10, 500, 250); theWindow.setLayout(null); theWindow.setVisible(true); head = new Oval(110, 70, 80, 80 ); theWindow.add(head, 0); head.repaint(); frontSegment = new Oval(180, 100, 50, 50); theWindow.add(frontSegment, 0); frontSegment.repaint(); midSegment = new Oval(230, 100, 0, 50); theWindow.add(midSegment, 0); midSegment.repaint(); rearSegment = new Oval(180, 100, 50, 50); theWindow.add(rearSegment, 0); rearSegment.repaint(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?