diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3403.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing3403.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3403.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3403.java new file mode 100644 index 0000000..82460eb --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3403.java @@ -0,0 +1,43 @@ +/* Listing3403.java */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class Listing3403
+extends Frame
+{
+ private Image img;
+
+ public static void main(String[] args)
+ {
+ Listing3403 wnd = new Listing3403();
+ }
+
+ public Listing3403()
+ {
+ super("Bitmap");
+ setBackground(Color.lightGray);
+ setSize(250,150);
+ setVisible(true);
+ //WindowListener
+ addWindowListener(new WindowClosingAdapter(true));
+ //Bild laden
+ img = getToolkit().getImage("duke.gif");
+ MediaTracker mt = new MediaTracker(this);
+ mt.addImage(img, 0);
+ try {
+ //Warten, bis das Image vollständig geladen ist,
+ mt.waitForAll();
+ } catch (InterruptedException e) {
+ //nothing
+ }
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ if (img != null) {
+ g.drawImage(img,40,40,this);
+ }
+ }
+}
\ No newline at end of file |
