aspose file tools
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 The Software Craftsman this week in the Agile 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: 10695

Check out AbstractButton#setRolloverEnabled and JButton#setRolloverIcon

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Have you tried LearnNowOnline?
subject: JButton size changes