• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to crop image in java

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Please UseCodeTags. You can edit your post to add them.

2)

How to show it to image label
image.setIcon(ima); is having error so how i can i do it


What's the error? Please TellTheDetails.
 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In crop image function what should i do after line no 43
 
Rob Spoor
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ima is an Image, not an Icon. Check out what methods your "icon" variable has, then use that variable in the call to setIcon.

This would have been easier to find out if you would have posted the error as I has asked you. Now I'm actually guessing this is the problem (but it probably is).
 
Vivek Moyal
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done much work over it . I m getting the image on other frame from Jfilechooser and from that frame i have to crop the image and this image is showing in label

and now i want to crop some area of image so that i can use the image which is worth to me.

So i dont know how to crop the image in cropImage() function i m doing the croping but i dont how to do it and at last when the crop is compelete i want to put the cropped image at other label from where i can save it in database i think now this is clear so now pleasehelp me
 
Rob Spoor
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ima is an Image. image is a JLabel. It's setIcon method requires an Icon. Is Image compatible with Icon? I don't think so. Is there some class or object that is? Yes there is, and you even have an instance of that: icon.

Can you find a method of icon that allows you to change its image? I'm sure you can. Once you've done that I'm sure you'll be able to set the Icon of image. After all, you then have an Icon with the cropped image.
 
reply
    Bookmark Topic Watch Topic
  • New Topic