@@ -58,10 +58,8 @@ public class MaterialSwitch extends MaterialWidget implements HasValue<Boolean>,
5858 private Span span = new Span ();
5959 private Label label = new Label ();
6060 private MaterialLabel lblError = new MaterialLabel ();
61- private String onLabel = "" ;
62- private Span onLabelSpan = new Span ();
63- private String offLabel = "" ;
64- private Span offLabelSpan = new Span ();
61+ private Span onLabel = new Span ();
62+ private Span offLabel = new Span ();
6563
6664 private final ErrorMixin <MaterialSwitch , MaterialLabel > errorMixin = new ErrorMixin <>(this , lblError , null );
6765
@@ -85,8 +83,8 @@ public MaterialSwitch(boolean value) {
8583 @ Override
8684 protected void onLoad () {
8785 super .onLoad ();
88- if (!offLabel .isEmpty ()) {
89- label .add (offLabelSpan );
86+ if (!offLabel .getText (). isEmpty ()) {
87+ label .add (offLabel );
9088 }
9189 label .add (input );
9290 label .add (span );
@@ -104,8 +102,8 @@ public void onClick(ClickEvent event) {
104102 event .stopPropagation ();
105103 }
106104 });
107- if (!onLabel .isEmpty ()) {
108- label .add (onLabelSpan );
105+ if (!onLabel .getText (). isEmpty ()) {
106+ label .add (onLabel );
109107 }
110108 }
111109
@@ -231,21 +229,17 @@ public void clearErrorOrSuccess() {
231229 errorMixin .clearErrorOrSuccess ();
232230 }
233231
234- public String getOnLabel () {
235- return onLabel ;
236- }
237-
238- public void setOnLabel (String onLabel ) {
239- this .onLabel = onLabel ;
240- onLabelSpan .setText (onLabel );
241- }
242-
243- public String getOffLabel () {
244- return offLabel ;
232+ /**
233+ * Set the On State Label of the switch component
234+ */
235+ public void setOnLabel (String label ) {
236+ onLabel .setText (label );
245237 }
246238
247- public void setOffLabel (String offLabel ) {
248- this .offLabel = offLabel ;
249- offLabelSpan .setText (offLabel );
239+ /**
240+ * Set the Off State Label of the switch component
241+ */
242+ public void setOffLabel (String label ) {
243+ offLabel .setText (label );
250244 }
251245}
0 commit comments