driver.java

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

JAVA
36
字号
import java.awt.Color;import javax.swing.JFrame;/**	Author: David D. Riley *		Date: Jan, 2005 *   Example of clipping and overlapping *   Rectangles and Ovals (Figure 3.20) */public class Driver  {    private JFrame  window;    private Rectangle bigSquare, smallSquare;    private Oval blackOval, whiteOval;        public Driver()  {        window = new JFrame( "the window" );	        window.setBounds(50, 50, 300, 200);        window.setLayout(null);        window.setBackground(Color.white);        window.setVisible(true);	                blackOval = new Oval(100, 100, 100, 40);        window.add(blackOval, 0);        bigSquare = new Rectangle(50, 20, 100, 100);        bigSquare.setBackground(Color.lightGray);        blackOval.add(bigSquare, 0);        smallSquare = new Rectangle(200, 30, 40, 40);        smallSquare.setBackground(Color.gray);        window.add(smallSquare, 0);        whiteOval = new Oval(210, 50, 20, 15);        whiteOval.setBackground(Color.white);        window.add(whiteOval, 0);        window.repaint();    }}

⌨️ 快捷键说明

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