I want to create a button that has 2 (or more) images inside (left and right of button). I researched but have not idea. Can you help me?
Asked
Active
Viewed 691 times
-2
-
search Google... please post what you have tried so for.. – pcs Jun 09 '15 at 04:00
-
please show us some code. – muglio Jun 09 '15 at 04:01
-
do you want the images on the button or beside the button? – BevynQ Jun 09 '15 at 04:02
-
@BevynQ: images on the button, BevynQ. – Phạm Quốc Bảo Jun 09 '15 at 04:03
-
1You could always create a transparent image then draw one icon to the right, one to the left, and the button 'text' as a string in between. But really, what is the point of this non-standard (and therefore not 'path of least surprise') GUI component for the end user? – Andrew Thompson Jun 09 '15 at 04:43
-
1direct way is to add two JLabels with Icons to JButton, by using BoderLayout to add one to EAST, 2nd to WEST area, then you must little bit to play with visibility of the JButtons text – mKorbel Jun 09 '15 at 05:17
-
This [example](http://stackoverflow.com/a/6036048/230513) uses two buttons to alter one image – trashgod Jun 09 '15 at 10:37
2 Answers
0
use this code for every button
JButton left_btn = new JButton(new ImageIcon("image_address"));
JButton right_btn = new JButton(new ImageIcon("image_address"));

A.K.
- 2,284
- 3
- 26
- 35
0
You can use the Compound Icon. It is a custom Icon
that allows you to combine two icons into one. So you can combine two ImageIcons
into one. Then you add the CompoundIcon
to the button.

camickr
- 321,443
- 19
- 166
- 288