Re: JButton with Multiple ImageIcons



Steve W. Jackson wrote:
In article <541732aa-8ed2-46fc-9b8a-826bcd956742@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
karlschmitt1969@xxxxxxxxxxxxxx wrote:

Hi,

I am evaluating the Java Swing toolkit
for a new project, and I would like to ask
if it is possible to add or place more than one ImageIcon
on top of a JButton?

Furthermore, is it possible to add multiple Strings with diffrent
text sizes and in diffrent fonts between to ImageIcons on to
a JButton surface.

____________________
| |
| <One Big Picture> |
| <Big Text> |
| <Small Text> |
| <Small Pictures> |
-----------------------------------|

Thanks in advance,

Karl

If you work hard enough, practically anything *might* be possible to put on a JButton. But the real question is why you might want to try such a thing.

A JButton represents a pushbutton, where you click it in order to invoke some action. If your goal is to display various images and text, it might be better to use multiple components for that purpose. If merely for display, you could use JLabel. If the idea is that interaction with a different part of the "button" invokes different actions, then multiple buttons (and even JLabels or other things) might be a more appropriate solution.
More specifically, since JComponent is a container, all JComponent descendants are also containers. You can put a JPanel with all those things inside it into a JButton.

Steve is right though, you should ask yourself not "is it possible", but "is it sensible."

Good luck.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
.


Quantcast