summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java73
1 files changed, 73 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java
new file mode 100644
index 0000000..42c8f4f
--- /dev/null
+++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing3408.java
@@ -0,0 +1,73 @@
+/* Listing3408.java */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class Listing3408
+extends Frame
+implements Runnable
+{
+ Thread th;
+ Image[] arImg;
+ int actimage;
+
+ public static void main(String[] args)
+ {
+ Listing3408 wnd = new Listing3408();
+ wnd.setSize(200,150);
+ wnd.setVisible(true);
+ wnd.startAnimation();
+ }
+
+ public Listing3408()
+ {
+ super("Bitmap-Folge");
+ addWindowListener(new WindowClosingAdapter(true));
+ }
+
+ public void startAnimation()
+ {
+ th = new Thread(this);
+ actimage = -1;
+ th.start();
+ }
+
+ public void run()
+ {
+ //Bilder laden
+ arImg = new Image[30];
+ MediaTracker mt = new MediaTracker(this);
+ Toolkit tk = getToolkit();
+ for (int i = 1; i <= 30; ++i) {
+ arImg[i-1] = tk.getImage("images/jana"+i+".gif");
+ mt.addImage(arImg[i-1], 0);
+ actimage = -i;
+ repaint();
+ try {
+ mt.waitForAll();
+ } catch (InterruptedException e) {
+ //nothing
+ }
+ }
+ //Animation beginnen
+ actimage = 0;
+ while (true) {
+ repaint();
+ actimage = (actimage + 1) % 30;
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ //nichts
+ }
+ }
+ }
+
+ public void paint(Graphics g)
+ {
+ if (actimage < 0) {
+ g.drawString("Lade Bitmap "+(-actimage),10,50);
+ } else {
+ g.drawImage(arImg[actimage],10,30,this);
+ }
+ }
+} \ No newline at end of file