Results 1 to 3 of 3
  1. #1
    Logical is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Question changing JButton image upon clicking

    Hello,

    I want to have a JButton's image change when it it clicked. I don't want it to just change for the click, but to remain the changed picture after the click. So I'm not looking for a method like "setPressedIcon." I would think that I could change the image by using setIcon in the action listener when the button is pressed, but it wasn't working. When I tried doing that, the picture just disappeared when I clicked the button and then after there was no picture at all. Is there something I'm missing? Or a better way to approach this?

    Thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by Logical View Post
    I want to have a JButton's image change when it it clicked. I don't want it to just change for the click, but to remain the changed picture after the click. So I'm not looking for a method like "setPressedIcon." I would think that I could change the image by using setIcon in the action listener when the button is pressed, but it wasn't working. When I tried doing that, the picture just disappeared when I clicked the button and then after there was no picture at all. Is there something I'm missing? Or a better way to approach this?
    Yeah, we need to see code to see where your mistakes are, otherwise it will be difficult to help you. Please look at my link on how to create an SSCCE to see just what type of code we need to see.

  3. #3
    Logical is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

Similar Threads

  1. How to show the full resolution image at clicking on thumnail
    By amritpalpathak in forum New To Java
    Replies: 4
    Last Post: 12-01-2010, 04:43 PM
  2. Replies: 0
    Last Post: 08-14-2010, 10:09 AM
  3. Changing colors of an image in real time
    By chale in forum CLDC and MIDP
    Replies: 0
    Last Post: 05-06-2009, 03:04 PM
  4. adding Image to JButton
    By mayhewj7 in forum New To Java
    Replies: 3
    Last Post: 03-31-2009, 03:39 AM
  5. Changing images by clicking arrow buttons. help?
    By ashton in forum New To Java
    Replies: 3
    Last Post: 02-08-2009, 11:29 AM

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
  •