Here you can find the source of concatenateIcons(final Icon icon1, final Icon icon2)
Parameter | Description |
---|---|
icon1 | first icon to be concatenated (this will be on the left side) |
icon2 | second icon to be concatenated (this will be on the right side) |
public static Icon concatenateIcons(final Icon icon1, final Icon icon2)
//package com.java2s; //License from project: Apache License import java.awt.Component; import java.awt.Graphics; import javax.swing.Icon; public class Main { /**/*from w w w. j av a2 s . c om*/ * Concatenates 2 icons next to each other (in 1 row). * @param icon1 first icon to be concatenated (this will be on the left side) * @param icon2 second icon to be concatenated (this will be on the right side) * @return an icon that is the result of the concatenation of the 2 specified icons */ public static Icon concatenateIcons(final Icon icon1, final Icon icon2) { return new Icon() { @Override public void paintIcon(final Component c, final Graphics g, final int x, final int y) { icon1.paintIcon(c, g, x, y); icon2.paintIcon(c, g, x + icon1.getIconWidth(), y); } @Override public int getIconWidth() { return icon1.getIconWidth() + icon2.getIconWidth(); } @Override public int getIconHeight() { return Math.max(icon1.getIconHeight(), icon2.getIconHeight()); } }; } }