| | |
drawing question
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2006
Posts: 131
Reputation:
Solved Threads: 0
The problem is that I have an ArrayList which stores objects that contain a Shape (actually a Composite shape like a Car) and (x,y) coordinates. Suppose I'm supposed to retrieve each object and the coordinates for drawing. My question is, how do I draw an Shape on the screen at position (x,y)? I looked in the API but didn't find any set() or overloaded draw() methods.
You will need to take a look at the java.awt.Graphics and java.awt.Graphics2D classes. They provide methods to draw shapes to what is called a graphics context (eg screen, image, printer etc). So if you want to draw a shape to the screen in say a javax.swing gui, you override the paint method in an extension of JPanel (or a similar JComponent) and call Graphics.draw(Shape).
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Similar Threads
- Connection question - Perl + PostgreSQL (Perl)
- Drawing a circle in Borland C++ builder (was: Help Me!!!!!) (C++)
- Question about adobe illustator (Graphics and Multimedia)
- drawing (Java)
- any one fermilliar with php-nuke? I have a question. (Existing Scripts)
- NOOB question , graphical tiles (C++)
Other Threads in the Java Forum
- Previous Thread: Question about buttons
- Next Thread: Image Icon displays file name text
Views: 409 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
actuate android api apple applet application arguments array arrays automation balls binary bluetooth business chat class classes client code codesnippet collections component coordinates database defaultmethod doctype dragging draw ebook eclipse educational error event exception file fractal game givemetehcodez graphics gui helpwithhomework hql html ide image ingres input integer invokingapacheantprogrammatically j2me java javaprojects jmf jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie number numbers object oracle parameter php print problem program programming project recursion scanner screen server set size sms socket sort sql string sun swing swt tcp test threads time transfer tree udp windows





