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

📄 driver.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
import java.awt.Color;import javax.swing.JFrame;/**	Author: David D. Riley *		Date: Jan, 2005 *   Three Squares Program (Figure 4.10) */public class Driver  {	private JFrame  theWindow;	private Rectangle leftSquare, midSquare, rightSquare;	/**	post:	a window with three blue filled squares is drawn  */	public Driver()   {		theWindow = new JFrame("The Window");		theWindow.setBounds(10, 10, 450, 250);		theWindow.setLayout(null);		theWindow.setBackground(Color.white);		theWindow.setVisible(true);		leftSquare = new Rectangle(100, 100, 50, 50);		colorAndAdd(leftSquare, Color.blue);		midSquare = new Rectangle(200, 100, 50, 50);		colorAndAdd(midSquare, Color.blue);		rightSquare = new Rectangle(300, 100, 50, 50);		colorAndAdd(rightSquare, Color.blue);	}		/**	pre:	w has been instantiated  	 *			and r has been instantiated  	 *			and c is a valid Color	 *	post:	r is set to color c 	 *			and  r is added to theWindow   	 */	private  void  colorAndAdd(Rectangle r, Color c)   {        r.setBackground(c);        theWindow.add(r, 0);        r.repaint();	}}

⌨️ 快捷键说明

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