MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / SpanLabel

Class SpanLabel

CodenameOne/src/com/codename1/components/SpanLabel.java:67–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65///
66/// @author Shai Almog
67public class SpanLabel extends Container implements IconHolder, TextHolder {
68 private final Label icon;
69 private final Container iconWrapper;
70 private final TextArea text;
71 private int gap;
72 private boolean shouldLocalize = true;
73 private int preferredW = -1;
74
75 /// Default constructor will be useful when adding this to the GUI builder
76 public SpanLabel() {
77 this("");
78 }
79
80 /// Constructor accepting default text and uiid for the text
81 ///
82 /// #### Parameters
83 ///
84 /// - `txt`: the text
85 ///
86 /// - `textUiid`: the new text UIID
87 public SpanLabel(String txt, String textUiid) {
88 this(txt);
89 text.setUIID(textUiid);
90
91 updateGap();
92 }
93
94 /// Constructor accepting default text
95 public SpanLabel(String txt) {
96 setUIIDFinal("Container");
97 super.setLayout(new BorderLayout());
98 text = new TextArea(super.getUIManager().localize(txt, txt));
99 text.setActAsLabel(true);
100 text.setColumns(text.getText().length() + 1);
101 text.setGrowByContent(true);
102 text.setUIID("Label");
103 text.setEditable(false);
104 text.setFocusable(false);
105 icon = new Label();
106 icon.setUIID("icon");
107 iconWrapper = new Container(new FlowLayout(CENTER, CENTER));
108 iconWrapper.getAllStyles().stripMarginAndPadding();
109 iconWrapper.add(icon);
110 super.addComponent(BorderLayout.WEST, iconWrapper);
111 super.addComponent(BorderLayout.CENTER, BoxLayout.encloseYCenter(text));
112 updateGap();
113 }
114
115 @Override
116 public void styleChanged(String propertyName, Style source) {
117 super.styleChanged(propertyName, source);
118 if (Style.ICON_GAP.equals(propertyName)) {
119 int gap = source.getIconGap();
120 if (gap >= 0 && gap != getGap()) {
121 setGap(gap);
122 updateGap();
123 }
124 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected