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

📄 ww2.java

📁 金旭亮的java教案
💻 JAVA
字号:

class WarningWindow2 extends java.awt.Window {

    WarningWindow2(java.awt.Frame apple) { // constructor
        super(apple);
        setBackground(java.awt.Color.red);
    }

    public void setSize(int x, int y) { // overriding method
        int bigx = (int) (x*1.5);
        int bigy = (int) (y*1.5);
        super.setSize(bigx, bigy);
    }
}

// The method setSize() in WarningWindow2 replaces 
// or overrides the superclass's version of setSize() 
// when the method is invoked on a WarningWindow2 object. 
// C++ programmers will note that you do not need to 
// specifically point out to the compiler (with the C++ 'virtual' keyword)
// that overriding will take place. Here's some example code:

public class ww2 {
   public static void main(String args[]) {
        java.awt.Frame f = new java.awt.Frame();
        { 
          java.awt.Window w = new java.awt.Window(f);
          w.setSize(200,100);
          w.setVisible(true);
          w.setLocation(300,300);
        }
        { 
          java.awt.Window w = new WarningWindow2(f); // the only change
          w.setSize(200,100);
          w.setVisible(true);
          w.setLocation(370,370);
        }
   }

}

⌨️ 快捷键说明

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