GUI:多窗口展示

public class textFrame2 {
    public static void main(String[] args) {
        //展示多个窗口

        myFrame f1 = new myFrame(100, 100, 200, 200, Color.cyan);
        myFrame f2 = new myFrame(300, 100, 200, 200, Color.red);
        myFrame f3 = new myFrame(100, 300, 200, 200, Color.yellow);
        myFrame f4 = new myFrame(300, 300, 200, 200, Color.lightGray);
    }

 static 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);
        }
    }
}

你可能感兴趣的:(java,开发语言)