Results 1 to 8 of 8
  1. #1
    pratik041 is offline Member
    Join Date
    Apr 2012
    Location
    Bangalore
    Posts
    4
    Rep Power
    0

    Default How to create JFrame having shape and size equel to image?

    I want to create a JFrame which would be the shape and size of any image.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: How to create JFrame having shape and size equel to image?

    Moved from new to Java.

    Java images are always rectangular, so first define what you mean by the 'shape' of an image.

    How to Create Translucent and Shaped Windows (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    pratik041 is offline Member
    Join Date
    Apr 2012
    Location
    Bangalore
    Posts
    4
    Rep Power
    0

    Default Re: How to create JFrame having shape and size equel to image?

    shape of image means suppose i have oval shape image (here i am referring to the opaque pixels only not the transparent pixels). How i can make the oval shape JFrame same as the size and shape of image .

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: How to create JFrame having shape and size equel to image?

    I gave you a link to a tutorial. Did you go through it?

    And by 'go through' I don't mean 'glance at'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    pratik041 is offline Member
    Join Date
    Apr 2012
    Location
    Bangalore
    Posts
    4
    Rep Power
    0

    Default Re: How to create JFrame having shape and size equel to image?

    I went through the article but one doubt i have how can we calculate the shape of image. So that we can use setshape function.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: How to create JFrame having shape and size equel to image?

    Do you know how to obtain the pixels of an image?
    Do you know how to iterate over them?
    Do you know how to identify a transparent color?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    pratik041 is offline Member
    Join Date
    Apr 2012
    Location
    Bangalore
    Posts
    4
    Rep Power
    0

    Default Re: How to create JFrame having shape and size equel to image?

    I know all the above mentioned points but how it will help to create the shape?

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: How to create JFrame having shape and size equel to image?

    Read the API for Shape. Go through the list of classes that implement Shape. Find one that you can assemble from the non-transparent pixels, or from the boundary between transparent and non-transparent pixels.

    This is your project, and it's not entirely trivial. You need to try out stuff yourself. Post back if you encounter a specific problem with which other members may (or may not) be able to help.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. create own shape
    By kepep in forum Java 2D
    Replies: 2
    Last Post: 12-15-2010, 07:43 PM
  2. Replies: 1
    Last Post: 04-02-2010, 12:48 PM
  3. Change the shape of JFrame
    By kiki2009 in forum New To Java
    Replies: 4
    Last Post: 07-09-2009, 01:47 PM
  4. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  5. Image size in a JFrame
    By nickbeacroft in forum AWT / Swing
    Replies: 2
    Last Post: 06-26-2008, 04:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •