• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Image in place of buttons

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I wanna use image as buttons in place of simple buttons provided by java.awt package, in addition to this, I also wanna change mouse cursor to 'hand' whenever the mouse has come over that image. But dont know how to go about all this. Can anyone help me out !!!
Regards and thanx in advance,
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Images(Icons) cant be displayed in Button class provided by java.awt package because it is an OS widget . The most you can try is that u can extend Button class & override its paint method draw image there it will be shown instead of rectangular button but i havent tested it in detail & i got poor results you better use swing JButton.
You can change the curosr on the button by using setCursor(Cursor cursor) of the Component class super class of every component in java.
Check java documentation for details.

[This message has been edited by Jahanzeb Sayal (edited April 21, 2001).]
 
Sam Cala
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Using swing is totally out of consideration as my clients are all web based and even the latest versions of popular browsers doesnt support swing. The clients will need to download the plugin first and then only they can acces my swing enabled site.
Is there some other way out ?
regards and thanks ,
 
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
I have previously posted code to how to make an image button in this thread...
As far as changing the cursor goes... simply add a MouseListener to your button and do a setCursor( Cursor c) on a mouseEntered event, and set it back to the old cursor on the mouseExited event... look at the Cursor class in the API to find out what cursor you need to send to setCurser to get the hand... I think it is Cursor.HAND_CURSOR...
So, you would have something like this in your mouse listener...


HTH,
-Nate
[This message has been edited by Nathan Pruett (edited April 23, 2001).]
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,
java.awt does not support the icon property associated with
a button. However, the same functionality can be done with swing's JButton.

Please note an extra space after the < applet tag and < /applet tag .


[This message has been edited by Ravindra Mohan (edited April 24, 2001).]
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic