PROGRAM:
/*<applet code = bresen height=400 width= 400>
</applet>*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class bresen extends Applet implements ActionListener {
Label l1 = new Label("x1 = ");
Label l2 = new Label("x2 = ");
Label l3 = new Label("y1 = ");
Label l4 = new Label("y2 = ");
TextField t1 = new TextField(3);
TextField t2 = new TextField(3);
TextField t3 = new TextField(3);
TextField t4 = new TextField(3);
Button bw = new Button("DRAW");
public void init(){
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l4);
add(t4);
add(bw);
bw.addActionListener(this);
}
public void paint(Graphics g)
{
int x1=Integer.parseInt(t1.getText());
int x2=Integer.parseInt(t2.getText());
int y1=Integer.parseInt(t3.getText());
int y2=Integer.parseInt(t4.getText());
int dx=x2-x1;
int dy=y2-y1;
int count=dx;
int p=2*dy-dx;
int xend,X,Y;
if(x1>x2){
X=x2;
Y=y2;
xend=x1;
}
else
{
X=x1;
Y=y1;
xend=x2;
}
g.drawString(".",X,Y);
while(count>0)
{
X+=1;
if(p<0)
{
p=p+2*dy;
}
else
{
Y+=1;
p=p+2*(dy-dx);
}
g.drawString(".",X,Y);
count--;
}
}
public void actionPerformed(ActionEvent aw)
{
repaint();
}
}
This comment has been removed by a blog administrator.
ReplyDeleteIt's interesting that many of the bloggers to helped clarify a few things for me as well as giving.
ReplyDeleteMost of ideas can be nice content.The people to give them a good shake to get your point and across the command.
Java training in Chennai
Java training in Bangalore
Java online training
Java training in Pune
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeletepython Online training in chennai
python training institute in marathahalli
python training institute in btm
Python training course in Chennai
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteAWS Training in Bangalore with Placements | AWS Training in Bangalore Cost
AWS Training in Pune With Placement | AWS Devops Training in Pune
AWS Online Training | AWS Online Training Cost
AWS Training in Bangalore cost| Aws training in Bangalore Besant Technologies
Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.
ReplyDeleteBest Devops online Training
Online DevOps Certification Course - Gangboard
If we want to draw a vertical line in which x1 and x2 values are same and y1 and y2 values should be increased then I think this program is not executing
ReplyDeleteIf is there any solution please share to me
The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea
ReplyDeleteJava training in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Online Training