Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 2d graphics

 
aswen singh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic