![]() |
2D Graphics in Java
Here's my situation. I've been thrown into an assignment involving 2D graphics. My assignment is to draw a line. I've been reading the java docs and staring at example code and I just don't get any of it. I know that I have to use Point2D to select different points and then Line2D to draw a line segment and Graphics2D to draw it to the screen but I just don't understand how I'm to use any of the classes. I need a Graphics2D object but I can't instantialize an object because it's an abstract class. Can anyone offer me some advice or point me to a nice tutorial explaining everything?
I'm coding in Java 6. |
Re: 2D Graphics in Java
What do you have so far?
This might help a bit: http://java.sun.com/docs/books/tutor...swing/TOC.html |
Re: 2D Graphics in Java
That's the hard part. I can't accept any help from anyone on the assignment directly. It includes generous users on a programming forum. I'm just looking for a simple example of setting up a Jpanel and using Java classes to draw simple 2D objects on it.
|
Re: 2D Graphics in Java
Hopefully this helps a bit...
:
import java.awt.*;Also this might help you a bit: http://www.corewebprogramming.com/PDF/ch10.pdf |
Re: 2D Graphics in Java
@Wizard1988: the Window is empty for me. java 1.5, ubuntu 7.10. used command line tools to compile and run.
|
Re: 2D Graphics in Java
1 Attachment(s)
@mrynit: You might need a new computer... Just kidding. I am not sure why it isn't working for you. There should be a bright green(unfilled) rectangle in the top right corner.
Try adding "g.fillRect(200,250,20,20);" at the end of the paint method, it might be easier to notice, or change the color to RED "g.setColor(Color.RED);" This is what I get: Attachment 611 |
| All times are GMT -5. The time now is 3:39 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC