📄 animationarea.java
字号:
package graphicAnimation;
import java.awt.*;
import javax.swing.*;
/**
* 演示区域,用于演示器在该区域绘制演示场景
* @author 周晓聪
* @since 2007/7/16
*/
public class AnimationArea extends JComponent {
private static final long serialVersionUID = 1L;
protected Animator animator = null; // 使用演示区域的演示器
protected int width; // 演示区域的最佳宽度
protected int height; // 演示区域的最佳高度
public AnimationArea(int width, int height) {
this.width = width; this.height = height;
}
public void setAnimator(Animator animator) {
this.animator = animator;
}
public Animator getAnimator() {
return animator;
}
public void setPreferredSize(int width, int height) {
this.width = width;
this.height = height;
}
public Dimension getPreferredSize() {
return new Dimension(width, height);
}
/**
* 构建的绘制方法,调用使用演示区域的演示器的 paint() 方法完成绘制
*/
protected void paintComponent(Graphics gc) {
if (animator != null) animator.paint(gc);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -