driver.java

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

JAVA
46
字号
import java.awt.*;import javax.swing.JFrame;/**	Author: David D. Riley *		Date: Jan, 2005 *   Creating Labels (Figure 3.12) */public class Driver  {	private JFrame  window;	private Label cityEngland, cityFrance, cityJapan, cityUSA;    	public Driver()  {		window = new JFrame( "Cities of the World" );			window.setBounds(50, 50, 400, 300);		window.setLayout(null);		window.setBackground(Color.white);		window.setVisible(true);		cityEngland = new Label( "London" );		cityEngland.setBounds(100, 200, 120, 20);		cityEngland.setForeground(Color.green);		window.add(cityEngland,0);		cityEngland.repaint();        		cityFrance = new Label ( "Paris" );		cityFrance.setBounds(250, 30, 100, 20);		cityFrance.setForeground(Color.blue);		window.add(cityFrance,0);		cityFrance.repaint();        		cityJapan = new Label ( "Tokyo" );		cityJapan.setBounds(30, 75, 100, 20);		cityJapan.setForeground(Color.red);		window.add(cityJapan,0);		cityJapan.repaint();        		cityUSA = new Label ( "New York City" );		cityUSA.setBounds(225, 250, 150, 20);		cityUSA.setForeground(Color.white);		cityUSA.setBackground(Color.blue);		window.add(cityUSA,0);		cityUSA.repaint();		window.repaint();	}}

⌨️ 快捷键说明

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