This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
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,
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).]
Joined: Jan 03, 2001
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 ,
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).]
Write once, run anywhere, because there's nowhere to hide! - /. A.C.