ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
2503
2503
EMPFEHLEN
-
19.12.04 20:12 #1trispo Tutorials.de Gastzugang
Hallo Leute,
habe folgendes Problem:
ich möchte in SWT eine Grafik mittels for-Schleife aktualisieren. Das funktioniert auch schon, aber ich möchte nun, dass ich jeden Schleifendurchlauf sehen und nicht nur das Endergebnis.
Gibt es in SWT irgendwie ein wait() oder so eine Art Timer-Funktion? Wie benutze ich die in meine for-Schleife?
Bin absoluter Newbie, also entschludigt, wenn ich so banale Sachen fragen!
-
27.12.04 23:00 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Schau mal hier:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
/* * Created on 27.12.2004@22:51:16 * * TODO Licence info */ package de.tutorials; import java.util.Timer; import java.util.TimerTask; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** * @author Administrator * * TODO Explain what I do... */ public class SWTGFXUpdate { private int x; private int y = 120; private final static long SLEEP = 150L; public static void main(String[] args) { new SWTGFXUpdate().run(); } /** * */ private void run() { Display display = new Display(); Shell shell = new Shell(); shell.setText("SWTResize"); Canvas canvas = new Canvas(shell, SWT.NONE); canvas.setSize(320, 240); final GC gc = new GC(canvas); Timer timer = new Timer(); timer.schedule(new TimerTask() { public void run() { int oldX = x; int oldY = y; x += 2; y = 120 + (int) (Math.sin(x) * 50); gc.drawLine(oldX, oldY, x, y); } }, 50L, SLEEP); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.isDisposed()) { display.readAndDispatch(); } } timer.cancel(); } }
Gruß TomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
Timer in C++
Von AirsoftDivisionHRO im Forum C/C++Antworten: 5Letzter Beitrag: 20.01.08, 14:51 -
vba timer
Von RulerofDarkness im Forum Visual Basic 6.0Antworten: 3Letzter Beitrag: 30.11.05, 14:49 -
Timer
Von Dark Ranger im Forum Visual Basic 6.0Antworten: 7Letzter Beitrag: 09.10.05, 20:02 -
Timer
Von Jai im Forum Visual Basic 6.0Antworten: 2Letzter Beitrag: 08.09.05, 11:01 -
OOP-Timer
Von Adam Wille im Forum Flash PlattformAntworten: 11Letzter Beitrag: 07.10.02, 23:30





Zitieren

Login





