package com.asmn.sudoku;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MainGame extends JPanel {
static int width, height;
//屏幕缩放倍数
int multiple;
public MainGame(){
multiple = 2;
width = 1920/multiple;
height = 1080/multiple;
}
@Override
public void paint(Graphics gl){
gl.setColor(Color.BLUE);
gl.fillRect(0, 0, width, height);
}
public static void main(String[] args) {
JFrame window = new JFrame();
MainGame game = new MainGame();
window.setSize(width, height);
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.add(game);
window.setVisible(true);
}
}
JFrame作为显示的窗口容器,JPanel则是容器里面的资源