📄 usecompositionexample.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 + -