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

📄 driver.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
import java.awt.*;import javax.swing.JFrame;/**	Author: David D. Riley *		Date: Jan, 2005 *   Bordered Signs Program (Figure 4.19) */	public class Driver  {	private JFrame  window;	private Rectangle topSign, bottomSign;	/**	post:	a window with two bordered signs is drawn  */	public Driver()   {		window = new JFrame("The Window");		window.setBounds(10, 10, 250, 180);		window.setLayout(null);		window.setBackground(Color.white);		window.setVisible(true);		topSign = borderedSign( Color.green, "Home, Sweet Home" );		topSign.setLocation(50, 20);        window.add( topSign, 0 );                bottomSign = borderedSign( Color.red, "Computers Rule!" );        bottomSign.setLocation(50, 90);        window.add( bottomSign, 0 );        window.repaint();	}		/**	post:	result == a rectangle that is 150 pixels wide and 50 pixels high     *          and  result has a border colored gray with mitered corners	 *			and  the message s is displayed on result     *          and  the colof of the center of result is c	 */	private  Rectangle  borderedSign(Color c, String s)   {        Rectangle result;        Line upperLeft, upperRight, lowerLeft, lowerRight;        Label message;         result = new Rectangle(0, 0, 150, 50);        result.setBackground( Color.lightGray );        upperLeft = new Line(0, 0, 9, 9);        result.add(upperLeft, 0);        upperRight = new Line(149, 0, 140, 9);        result.add(upperRight, 0);        lowerLeft = new Line(0, 49, 9, 40);        result.add(lowerLeft, 0);        lowerRight = new Line(149, 49, 140, 40);        result.add(lowerRight, 0);        message = new Label(s);        message.setBounds(10, 10, 130, 30);        message.setBackground(c);        result.add(message, 0);        return result;	}}

⌨️ 快捷键说明

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