Results 1 to 6 of 6
- 05-21-2012, 08:57 AM #1
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
[SOLVED] How would you go about adding text and images to a button or label?
I am trying to do something like what I have posted below in that image where the 1s are variables I would want to be able to change at runtime and the colored squares are images. I was thinking this might be done on a button or label with image icons or something similar, the images will not need to be changed, just the variables. I am not even sure if this could be done on 1 button or label or if it needs to be done on 3.
Any help would be appreciated

*edit*
As a sidenote, if anyone could tell me how to size an image programmatically that would also be very helpful, as it is I have just been resizing with fireworks.Last edited by goatjugsoup; 05-21-2012 at 10:19 AM.
- 05-21-2012, 09:14 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: How would you go about adding text and images to a button or label?
The JButtons and Jabels have a setText( ... ) and setIcon( ... ) method together with a couple of allignment methods. Don't they suffice?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-21-2012, 09:20 AM #3
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: How would you go about adding text and images to a button or label?
I have been looking at those and if I end up having to use 3 different buttons, 1 for each paring of text and image that method will work but as far as I know the setIcon won't allow you to have multiple icons. I'm really hoping there's a better way that I just don't know about but thanks for the reply.
- 05-21-2012, 09:44 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: How would you go about adding text and images to a button or label?
Rob Camick has a site full of tips and tricks; one of them describes how you can create a single Icon out of two (or more) Icons so you can stick them in a JLabel or JButton. Note that this isn't the only solution for displaying several Icons in a row ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-21-2012, 10:15 AM #5
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: How would you go about adding text and images to a button or label?
The link you provided looks interesting but I couldn't see anything there that would achieve what I wanted to do. I have messed around with 3 different labels and have gotten it to look as if I were doing it with 1 which is what I was trying to do so I guess thats good enough. Thanks for the tips anyway, the knowledge will probably help me out down the line.
- 05-21-2012, 10:33 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: How would you go about adding text and images to a button or label?
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
read images path from database and display it in label?
By prowael in forum New To JavaReplies: 3Last Post: 12-05-2011, 01:28 PM -
unicode ok for text pane but not for button label
By madroadbiker in forum Advanced JavaReplies: 6Last Post: 06-01-2011, 05:58 PM -
adding label to the anel of other class
By saranyabaskaran in forum New To JavaReplies: 6Last Post: 03-25-2011, 08:12 AM -
Adding a sqrt button and percentage button to a calculator
By Josie_Taylor in forum New To JavaReplies: 4Last Post: 03-14-2011, 01:16 AM -
Code for - On click of button current date & time should be assignesd to label.
By amartya51 in forum Suggestions & FeedbackReplies: 1Last Post: 08-16-2010, 10:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks