Results 1 to 6 of 6
  1. #1
    johny2011 is offline Member
    Join Date
    Apr 2011
    Posts
    28
    Rep Power
    0

    Default How to show image on images

    Hi All,

    I want to show an transparant image on another opaque image

    How can I handle it ? Any idea ?

    Also I want to pur little image icons on a bigger image which can handle mouse clicks.

    Think it just map-click web sites.

    I hope somebody can help me,..Thanks.

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

    Default

    Quote Originally Posted by johny2011 View Post
    I want to show an transparant image on another opaque image

    How can I handle it ? Any idea ?
    See the Java Tutorial on Drawing An Image. The 'Filtering Images' subsection shows you how to do this.

    Also I want to pur little image icons on a bigger image which can handle mouse clicks.
    An easy way to do this is to use JButtons for your image icons and set their borders to null so they display the icons without a button border. Then you can put the click action for each image in the button actionPerformed(..) method. The background image can be drawn onto the panel the buttons are displayed in.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    Quote Originally Posted by dlorde View Post
    An easy way to do this is to use JButtons for your image icons and set their borders to null ...
    Better:
    Java Code:
    setBorderPainted(false)
    setContentAreaFilled(false)
    // and maybe
    setFocusPainted(false)
    Also depends on what exactly should determine a mouse click. A JButton's action event is generated even when a mouse drag intervenes between a mouse pressed and released, so long as both the latter events are within the bounds of the button.

    For a literal mouse click -- a mouse press and release within some small, OS defined pizel range -- it may be better to use an Icon on a JLabel with a MouseListener.

    db

  4. #4
    johny2011 is offline Member
    Join Date
    Apr 2011
    Posts
    28
    Rep Power
    0

    Default

    Thanks for teh repplies, good idea! But I wonder if java does not provide sth like area-clickable image ?

    By the way, I know how to handle JButtons, but one point, when I placed buttons on the canvas, I want them placed on the desired positions. How can I be sure the seen properly on onother user? and with different screen resolutions.

    I mean, maybe the user should not change the size of tha canvas, can I do that ?
    I want to be seen buttons on the proper sectins of the background image.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    I wonder if java does not provide sth like area-clickable image ?
    I already told you how you can do that. It appears you need to get a foundation in several aspects of Swing.
    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    db

    edit And http://catb.org/~esr/faqs/smart-ques...html#writewell
    Last edited by DarrylBurke; 05-18-2011 at 10:54 AM.

  6. #6
    orchid1 is offline Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

Similar Threads

  1. JMenuItem - image won't show
    By javawriter in forum AWT / Swing
    Replies: 10
    Last Post: 07-13-2010, 06:11 PM
  2. show image that I refresh
    By erwillie in forum New To Java
    Replies: 1
    Last Post: 04-29-2010, 03:23 PM
  3. Replies: 0
    Last Post: 03-19-2010, 11:26 PM
  4. Can't show images onto the screen
    By javaexplorer in forum AWT / Swing
    Replies: 9
    Last Post: 01-14-2010, 06:31 PM
  5. Problems to show images in applets
    By Felissa in forum Java Applets
    Replies: 1
    Last Post: 07-06-2007, 09:12 PM

Posting Permissions

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