source: src/main/java/negotiator/onetomany/etc/Bob.java@ 222

Last change on this file since 222 was 220, checked in by Faria Nassiri Mofakham, 6 years ago

Bob works now! It shows Bob's image through updated GUI.

File size: 910 bytes
Line 
1package negotiator.onetomany.etc;
2
3import java.awt.Canvas;
4import java.awt.Graphics;
5import java.awt.Image;
6import java.awt.MediaTracker;
7import java.awt.Toolkit;
8
9
10/**
11 * @author Faria Nassiri-Mofakham
12 *
13 */
14public class Bob extends Canvas{
15
16 /**
17 *
18 */
19 private static final long serialVersionUID = 1L;
20 /**
21 *
22 */
23
24 Image image;
25
26 public Bob(String filename)
27 {
28 loadImage(filename);
29 }
30
31 public void paint(Graphics g)
32 {
33 g.drawImage(image, g.getClipBounds().x,g.getClipBounds().y, this);
34 }
35
36
37 public void loadImage(String f)
38 {
39 MediaTracker tracker = new MediaTracker(this);
40 image = Toolkit.getDefaultToolkit().getImage(f);
41 tracker.addImage(image, 0);
42 try
43 {
44 tracker.waitForID(0);
45 }
46 catch(InterruptedException ie)
47 {
48 System.out.println(ie.getMessage());
49 }
50 }
51}
52
53
54
55
Note: See TracBrowser for help on using the repository browser.