driver.java

来自「Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套」· Java 代码 · 共 48 行

JAVA
48
字号
import java.awt.*;/**	Author: David D. Riley *		Date: Jan, 2005 *   Program to illustrate events in recoloring a square (Figure 4.25) */	public class Driver extends ThreeButtons {	private ThreeButtonFrame  window;	private Rectangle square;	/** post:	a window with a 100 by 100 filled black square is drawn     *			and button actions control recoloring of the square       */	public Driver()   {		window = new ThreeButtonFrame("Square Recoloring Window");		window.setLayout(null);		square = new Rectangle(250, 150, 100, 100);		window.add(square, 0);		square.repaint();	}		/**	pre:	square is constructed		 *	post:	square is colored green  and  square is repainted   	 */	public  void  leftAction()   {		square.setBackground( Color.green );		square.repaint();	}	/**	pre:	square is constructed	     *	post:	square is colored red  and  square is repainted        */	public  void  midAction()   {		square.setBackground( Color.red );		square.repaint();	} 	/** 	pre:	square is constructed		 *	post:	square is colored blue  and  square is repainted   	 */	public  void  rightAction()   {		square.setBackground( Color.blue );		square.repaint();	}}

⌨️ 快捷键说明

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