Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / client / GraphicsPanel.java @ 637

History | View | Annotate | Download (542 Bytes)

1
import java.awt.*;
2
import javax.swing.*;
3

    
4
/*
5
* GraphicsPanel class
6
* An extension of JPanel, designed for holding an image that will be repainted regularly.
7
*/
8
public class GraphicsPanel extends JPanel {
9
        protected Image img;
10

    
11
        public GraphicsPanel (Image img) {
12
                this(img, true);
13
        }
14

    
15
        public GraphicsPanel (Image img, boolean isDoubleBuffered) {
16
                super(isDoubleBuffered);
17
                this.img = img;
18
        }
19

    
20
        public void paint (Graphics g) {
21
                // Place the buffered image on the screen, inside the panel
22
                g.drawImage(img, 0, 0, Color.WHITE, this);
23
        }
24
}