01: package org.swingml.component;
02:
03: import java.awt.*;
04:
05: import javax.swing.*;
06:
07: import org.swingml.*;
08:
09: public class LabelDecorator {
10:
11: public static void decorateLabel(JLabel aLabel,
12: SwingMLModel aModel, Font defaultFont) {
13: aLabel
14: .setFont(FontFactory.getFontForModel(aModel,
15: defaultFont));
16: if (aModel.getIcon() != null) {
17: ImageIcon icon = IconFactory.getIcon(aModel);
18: if (icon != null) {
19: aLabel.setIcon(icon);
20: }
21: } else {
22: aLabel.setIcon(null);
23: }
24: if (aModel.getForeground() != null) {
25: aLabel.setForeground(aModel.getForeground());
26: } else {
27: aLabel.setForeground(null);
28: }
29:
30: if (aModel.getBackground() != null) {
31: aLabel.setOpaque(true);
32: aLabel.setBackground(aModel.getBackground());
33: } else {
34: aLabel.setBackground(null);
35: }
36: }
37: }
|