diff --git a/Panel.java b/Panel.java index 6c14fee..9b2e3ed 100644 --- a/Panel.java +++ b/Panel.java @@ -1,37 +1,57 @@ -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; +import java.awt.*; import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; import javax.swing.JPanel; public class Panel extends JPanel { - int scale = 10; // Factor by which to scale books - int w = 4; // Number of columns of books - int h = 3; // Number of rows of books - int margin = 5; // Number of pixels between each book (will be scaled) + + int scale = 10; // Factor by which to scale books + int w = 12; // Number of columns of books + int h = 12; // Number of rows of books + int margin = 5; // Number of pixels between each book (will be scaled) + + BufferedImage bufferImage; + Graphics2D bufferGraphics; public Panel() { - setPreferredSize(new Dimension((Buch.width+margin)*scale*w, (Buch.height+margin)*scale*h)); + final int frameWidth = (Buch.width + margin) * scale * w; + final int frameHeight = (Buch.height + margin) * scale * h; + setPreferredSize(new Dimension(frameWidth, frameHeight)); + bufferImage = new BufferedImage(frameWidth, frameHeight, BufferedImage.TYPE_INT_ARGB); + bufferGraphics = bufferImage.createGraphics(); } //Draw all the books @Override public void paintComponent(Graphics g) { - g.setColor(new Color(108, 83, 83)); - g.fillRect(0, 0, getWidth(), getHeight()); - for (int i = 0; i