| | | | Browse by category |
Article ID: 1027
Last updated: 05 Feb, 2008
Problem
I am unable to create an ImageButton where the image is the same size as the button. I try to use the setSize() member function, but this does not seem to change the ImageButton. the way I want it to.
Cause
The getPreferredSize() member function of ImageButton overrides the setSize() function inherited from the canvas class.
Action
I am unable to create an ImageButton where the image is the same size as the button. I try to use the setSize() member function, but this does not seem to change the ImageButton. the way I want it to.
Cause
The getPreferredSize() member function of ImageButton overrides the setSize() function inherited from the canvas class.
Action
You will probably want to create a derived class from ImageButton that always returns the minimum size. This will produce an ImageButton that uses the size of the smallest associated button.
class MinimumSizedButton extends ImageButton {
public MinimumSizedButton(SerializableImage image) {
super(image);
}
public Dimension getPreferredSize() {
return getMinimumSize();
}
}
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 1027
Last updated: 05 Feb, 2008
Revision: 1
Views: 2716
Posted: 09 Mar, 1998 by
Dean J.
Updated: 05 Feb, 2008 by
Dean J.
Others in this category
Powered by KBPublisher (Knowledge base software)