我有这个:
import javax.swing.*;
import java.awt.Canvas;
import java.awt.image.BufferedImage;
public class test extends Canvas{
public static JFrame frame;
public static int WIDTH = 800;
public static int HEIGHT = 600;
public static BufferedImage img;
public static int[] pixels;
public static boolean running=true;
public static void main(String[] a){
img = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RGB);
frame = new JFrame("WINDOWw");
frame.add(new JLabel(new ImageIcon(img)));
frame.pack();
frame.setVisible(true);
frame.setSize(WIDTH, HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
如何阻止黑色图像在框架上自动居中?