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

📄 usecompositionexample.java

📁 金旭亮的java教案
💻 JAVA
字号:
import java.awt.*; 
public class UseCompositionExample { 
	
	SimplestWindow sw;  //使用组合对象
	
	public UseCompositionExample()
	{
	   sw=new SimplestWindow();
       sw.SetBackground(Color.red);
       sw.Show();
	}
	
   	public static void main(String args[]) {
      UseCompositionExample redW=new UseCompositionExample();
    } 
}



 class SimplestWindow { 
	private Window w;
	private Frame f;
	
	public SimplestWindow()
	{	f = new Frame();// Window must belong to a Frame
        w = new Window(f);//生成一个窗口
 	} 
	
	public void SetBackground(Color clr)
	{
		w.setBackground(clr);
	}
	
	public void Show()
	{
		w.setSize(200,100);
        w.setVisible(true);
        w.setLocation(50,50);
	}
	
   
}

⌨️ 快捷键说明

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