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

Custom (image) button

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have my own image in my applet to act as Button. So, I'll have different images -- for Enabled button status, Disabled, with Mouse Over It, when it is Pressed, etc.
But how to create it as a button? The only thing I found is to have regular Button (JButton) _inside_ of which we can have an image. But nothing more...
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JButton has setDiabledIcon(), setDisabledSelectedIcon(), setIcon(), setPressedIcon(), setRolloverIcon(), setRolloverSelectedIcon(), and setSelectedIcon() - all inherited from javax.swing.AbstractButton.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Panda Mima:
I want to have my own image in my applet to act as Button. So, I'll have different images -- for Enabled button status, Disabled, with Mouse Over It, when it is Pressed, etc.
But how to create it as a button? The only thing I found is to have regular Button (JButton) _inside_ of which we can have an image. But nothing more...



In addition to the methods Mr. Pruett mentioned, there are also setBorderPainted(), setContentAreaFilled(), and setFocusPainted().

Set these to false if you want the button to appear as an unadorned image.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic