• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic