0

I have got a JPanel with a dimensions x,y. What im doing is a drawing an moving image with paintComponent() and Graphics2D.drawImage() metods. I want to ask, how to draw one part of image on one side of panel and part on second part on 2nd side of my panel when it will move my image to the edge of JPanel. What i want to do is for example:

my image has got dimensions 20,20

my panel has got dimensions 100,100

when i move my image to position 90,10 (x,y) i want to draw half of my image on position 90,10 and 2nd half on position 0,10

  • Draw two images in that case - the appropriate parts of the original image at the left and right side. – Martin Dinov Dec 26 '13 at 23:12
  • @MartinDinov thats obvious for me however how to draw part of my orginal image? –  Dec 26 '13 at 23:20
  • There's a version of the drawImage method that lets you specify how far into the x and y directions you want to draw, essentially letting you draw parts of the image only. See here: http://stackoverflow.com/questions/9677661/drawing-a-part-of-an-image-java – Martin Dinov Dec 26 '13 at 23:38

0 Answers0