Skip to main content

create button with image and text

2 replies [Last post]
Joined: 2007-12-31


I want to create a button with text and image.

I want the text to be upon the image and centered,, but couldn't find such option.

for example the following code make a button from an image but the text is under the image:

Button button = new Button("TEXT", image);

I tried as well to create the button with text only and to set the image as BG, but the button dimension fitted only the text not the image, so I couldn't see the full image:
Button button = new Button("TEXT");

is it possible to make the button fit the image size instead of the text in this case?

Thank you

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-12-31

I used setPreferredH(..) and setPreferredW(..) functions

Johannes Wahle