forked from prmr/DesignBook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompositeIcon.java
More file actions
50 lines (42 loc) · 881 Bytes
/
CompositeIcon.java
File metadata and controls
50 lines (42 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package chapter6;
import java.awt.Component;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Icon;
public class CompositeIcon implements Icon
{
private final List<Icon> aIcons = new ArrayList<>();
public void addIcon(Icon pIcon)
{
aIcons.add(pIcon);
}
@Override
public int getIconHeight()
{
int height = 0;
for( Icon icon : aIcons )
{
height = Math.max(height, icon.getIconHeight());
}
return height;
}
@Override
public int getIconWidth()
{
int width = 0;
for( Icon icon : aIcons )
{
width = Math.max(width, icon.getIconWidth());
}
return width;
}
@Override
public void paintIcon(Component pComponent, Graphics pGraphics, int pX, int pY)
{
for( Icon icon : aIcons)
{
icon.paintIcon(pComponent, pGraphics, pX, pY);
}
}
}