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

Class SpanButton

CodenameOne/src/com/codename1/components/SpanButton.java:63–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61///
62/// @author Shai Almog
63public class SpanButton extends Container implements ActionSource<ActionEvent>, SelectableIconHolder, TextHolder {
64
65 private final Button actualButton;
66 private final TextArea text;
67 private int gap = Label.getDefaultGap();
68 private boolean shouldLocalize = true;
69
70 /// Default constructor will be useful when adding this to the GUI builder
71 public SpanButton() {
72 this("");
73 }
74
75 /// Constructor accepting default text and uiid for the text
76 ///
77 /// #### Parameters
78 ///
79 /// - `txt`: the text
80 ///
81 /// - `textUiid`: the new text UIID
82 public SpanButton(String txt, String textUiid) {
83 this(txt);
84 text.setUIID(textUiid);
85 }
86
87 /// Constructor accepting default text
88 public SpanButton(String txt) {
89 setUIIDFinal("Button");
90 setLayout(new BorderLayout());
91 text = new TextArea(super.getUIManager().localize(txt, txt));
92 text.setColumns(100);
93 text.setUIID("Button");
94 text.setGrowByContent(true);
95 text.setEditable(false);
96 text.setFocusable(false);
97 text.setActAsLabel(true);
98 setFocusable(true);
99 removeBackground(text.getUnselectedStyle());
100 removeBackground(text.getSelectedStyle());
101 removeBackground(text.getPressedStyle());
102 removeBackground(text.getDisabledStyle());
103 actualButton = new Button();
104 actualButton.setUIID("icon");
105 super.addComponent(BorderLayout.WEST, actualButton);
106 Container center = BoxLayout.encloseYCenter(text);
107 center.getStyle().setMargin(0, 0, 0, 0);
108 center.getStyle().setPadding(0, 0, 0, 0);
109 super.addComponent(BorderLayout.CENTER, center);
110 setLeadComponent(actualButton);
111 updateGap();
112 }
113
114 @Override
115 public void styleChanged(String propertyName, Style source) {
116 super.styleChanged(propertyName, source);
117 if (Style.ICON_GAP.equals(propertyName)) {
118 int gap = source.getIconGap();
119 if (gap >= 0 && gap != getGap()) {
120 setGap(gap);

Callers

nothing calls this directly

Calls 1

getDefaultGapMethod · 0.95

Tested by

no test coverage detected