This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JButton size changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton size changes" Watch "JButton size changes" New topic

JButton size changes

rajshkhr pandey
Ranch Hand

Joined: Oct 14, 2009
Posts: 35
Hello to all,

I am developing an application in which I have used JToolBar with JButtons.
I am using the images instead of text as in following code

The image named save_big.jpg is of 20 X 20 and save.jpg is of 16 X 16
The problem arise when the mouse event occurs the button size resizes instead of the image i.e. on mouse entered event the button becomes big and on mouse exited event the button retains normal size as before.
I might be be because of the change in the size of image. I want the mouse hover effect on the button.
Also the image remains in the center of the button but I want the whole button to be covered by image.
Can anyone help me please.
Thank in advance
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10747

Check out AbstractButton#setRolloverEnabled and JButton#setRolloverIcon

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: JButton size changes
It's not a secret anymore!