Hi caliraj,
First of all, resizing a component inside a
FlowLayout is pratically impossible as the layout manager will put components sequentially in a row according their preferred size, either from left to right (default) or from top to bottom. In a FlowLayout, components are in a way interconnected.
Also, layout managers have their own set of rules that prevail on whatever method applied on a component. That means certain actions on the components can simply be ignored because they are violating one of the rules of the layout manager.
In your example, instead of implementing directly a variable size button, you may use a JPanel with a a size sufficiently large to contain a button. With the JPanel, you will have an independant container (nested container) in which you'll be able to resize your button according to the size of the image it will contains.
You should check the methods of the JButton :
http://java.sun.com/javase/6/docs/ap...g/JButton.html.