1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package aigames.soccer.observer;
21
22 import java.awt.Graphics;
23 import java.awt.Image;
24
25 import javax.swing.JPanel;
26
27
28 /***
29 * Panel for a field drawing.
30 * @version $Id: FieldPanel.java,v 1.4 2004/05/08 21:55:28 mwerla Exp $
31 */
32 public class FieldPanel extends JPanel {
33 private Image buffer = null;
34
35 /***
36 * Panel constructor.
37 */
38 public FieldPanel() {
39 super();
40 setOpaque(true);
41 }
42
43 /***
44 * Switch panel image.
45 * @param buffer
46 */
47 public void setImage(Image buffer) {
48 this.buffer = buffer;
49 }
50
51 /***
52 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
53 */
54 protected void paintComponent(Graphics g) {
55 if (null == buffer) {
56 super.paintComponent(g);
57 } else {
58 g.drawImage(buffer, 0, 0, getBackground(), this);
59 }
60 }
61 }