package slipapp; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.JPanel; /** * * @author Doys */ public class PanelWriter extends JPanel{ private int currentPage = 0; private BufferedImage[] buff; private int myWidth = 0; private int myHeight = 0; public PanelWriter(BufferedImage[] buff, int width, int height){ this.buff = buff; this.myWidth = width; this.myHeight = height; this.setSize(width, height); this.setPreferredSize(new Dimension(width, height)); } @Override public void paint(Graphics g){ g.setColor(Color.WHITE); g.fillRect(0, 0, myWidth, myHeight); if(buff == null) return; ((Graphics2D)g).drawImage(buff[currentPage], null, 0, 0); } public void setCurrentPage(int currentPage){ this.currentPage = currentPage; repaint(); } }