数组模式与应用详解
1. 数组模式概述
数组在编程中应用广泛,涉及众多模式,包括数组的初始化、大小更改以及各种算法。以下将介绍一些常见的数组模式。
2. 图像动画组件示例
以下代码展示了一个按顺序显示图像以产生动画效果的组件:
this.setPreferredSize(new Dimension(
this.images[0].getIconWidth(),
this.images[0].getIconHeight()));
}
/** Paint the current image on the screen. */
public void paintComponent(Graphics g)
{ super.paintComponent(g);
Image img = this.images[this.currentImage].getImage();
g.drawImage(img, 0, 0, null);
}
/** Run the animation. */
public void run()
{ while (true)
{ // Select the next image and call for the system to repaint the component.
// If this.dir is negative, the remainder operator doesn't work as desired. Add
// this.images.length to compensate.
超级会员免费看
订阅专栏 解锁全文
6万+

被折叠的 条评论
为什么被折叠?



