Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
URGENT: Problem in Applet using awt Posted by darksid3r on 20 Dec 2012 at 3:47 PM


I need to make an applet which shows two lines that are at a distance from each other and are moving towards each other and i have to show this until they meet at a point... for this i wrote the following code..


import java.applet.Applet;
import java.awt.*;

public class Drawing extends Applet{
int i;
int x=10;
int x1=50;
int x2=110,x3=150;
public void paint(Graphics g){
for(i=1;i<=4;i++){

g.setColor(Color.RED);
g.drawLine(x,10,x1,10);
g.setColor(Color.BLUE);
g.drawLine(x2,10,x3,10);
x=x+10;
x1=x1+10;
x2=x2-10;
x3=x3-10;
repaint();
}
}
}


But the problem here is that it gets repainted and i see nothing...IS THERE A WAY TO PAUSE EVERYTIME THE LINES ARE DRAWN so that one can see whats happening?
Thread Tree
darksid3r URGENT: Problem in Applet using awt on 20 Dec 2012 at 3:47 PM
Pelle-48 Re: URGENT: Problem in Applet using awt on 21 Dec 2012 at 8:37 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.