我是靠谱客的博主 欢呼煎蛋,这篇文章主要介绍GUI--02开多个窗口,现在分享给大家,希望可以做个参考。

 先定义接口MyFrame 继承 Frame

  在TestFrame02中实现

package com.liner.lesson01;

import java.awt.*;

public class TestFrame02 {
    public static void main(String[] args) {
        //展示多个窗口
        new MyFrame(100,100,200,200,Color.blue);
        new MyFrame(300,100,200,200,Color.yellow);
        new MyFrame(100,300,200,200,Color.red);
        new MyFrame(300,300,200,200,Color.magenta);
    }

}
class MyFrame extends Frame {
    static int id = 0;//可能存在多个窗口,我们需要一个接收器
    public MyFrame(int x,int y,int w,int h,Color color){
        super("MyFrame"+(++id));
        setBackground(color);
        setBounds(x, y, w, h);
        setVisible(true);
    }
}

 

最后

以上就是欢呼煎蛋最近收集整理的关于GUI--02开多个窗口的全部内容,更多相关GUI--02开多个窗口内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(125)

评论列表共有 0 条评论

立即
投稿
返回
顶部