useinheritsexample.java

来自「金旭亮的java教案」· Java 代码 · 共 33 行

JAVA
33
字号
import java.awt.*; 

public class UseInheritsExample { 
	
		
   public static void main(String args[]) {
      RedWindow redW=new RedWindow();
     
    }
}


 class SimplestWindow extends Window { 
	
			
	public SimplestWindow(Frame f)
	{	
		super(f); // Window must belong to a Frame
    
	} 
}

class RedWindow extends SimplestWindow
{
	public RedWindow()
	{
		super(new Frame());
		setBackground(Color.red);
        setSize(200,100);
        setVisible(true);
        setLocation(50,50);
	}
}

⌨️ 快捷键说明

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