File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Java 2d graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Java 2d graphics" Watch "Java 2d graphics" New topic

Java 2d graphics

aswen singh

Joined: Mar 31, 2012
Posts: 1
Guys i need help on the java graphics coding....basically this is my painter code....

Basically all i want is a rectangle that is red color with a stroke color (border) of black. But my question is how to set color for the stroke? i tried drawing the square then after that setPaint to black & draw again but dosent work that way either....been trying so many other ways & google-ing but couldnt find any result...

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
possibly create 2 rectangles
1) draw() - which will give you the black border
2) fill() - this is red and will be the inside, so the x,y,w,h will need to be adjusted for 'strokeValue'

don't know what you're doing, but might be a lot easier using a component
I agree. Here's the link:
subject: Java 2d graphics