Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Painting in Java

Status
Not open for further replies.

rastkocvetkovic

Programmer
Aug 11, 2002
63
SI
I'm having problems with java.awt.*;.

I would kindly ask if somebody has a simple application that uses canvas to draw a point at (x,y) position? Please, I'm in a hurry :|

Regards, Rastko
 
Override the paint method and use g.drawLine(x, y, x, y).

Otto
 
Hmm, I'm sorry, but I'm a rookie in Java and I can't understand what Override means. If you could give me a simple example, what it is i'll try.
But anyway, thank you for helping!
 
A simple copy and paste would be enough, because all I managed to find is how ti draw in applets ;(

Thanks in advance, Rastko
 
Here is a (really minimal :)) sample.
DrawTest.html:
<hr>
<applet code=DrawTest.class width=320 height=400>
Your browser not support JAVA</applet>
<hr>

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

public class DrawTest extends Applet {

public void paint(Graphics g) {
g.setColor(Color.red);
g.drawLine(0, 0, 100, 100);
g.setColor(Color.blue);
g.fillArc(0, 0, 50, 100, 0, 360);
}
}

Otto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top