public class MFrame extends JFrame {
public static void main(String[] args) {
new MFrame();
}
public MFrame() {
this.setTitle("五子棋小游戏");
this.setSize(500,500);
this.setLocationRelativeTo(null); //居中
this.setResizable(false); //不可调整大小
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); //按×关闭
this.setLayout(null);
JLabel boardLabel = new JLabel(new ImageIcon("imgs/rp.png"));
boardLabel.setSize(300,300);
boardLabel.setLocation(50,50);
add(boardLabel);
setVisible(true); //是否可见
}
}
使用Graphics2D类的setRenderingHint方法,将渲染质量设置为高质量即可
不知道你这个问题是否已经解决, 如果还没有解决的话:阻塞队列(BlockingQueue)是一个支持两个附加操作的队列。这两个附加的操作支持阻塞的插入和移除方法。
支持阻塞的插入方法offer:当队列满时,队列会阻塞插入元素的线程,直到队列不满。
支持阻塞的移除方法take:在队列为空时,获取元素的线程会等待队列变为非空。
阻塞队列常用于生产者和消费者的场景,生产者是向队列里添加元素的线程,消费者是从队列里取元素的线程。阻塞队列就是生产者用来存放元素、消费者用来获取元素的容器。
非阻塞队列:若队列为空从中获取元素则会返回空,若队列满了插入元素则会抛出异常。