• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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: 22848
132
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: 22848
132
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: 22848
132
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic