| | |
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
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql sqlserver string superclass swing system thread threads tree variablebinding windows xor





