]> source.dussan.org Git - vaadin-framework.git/commitdiff
Migrate ChangingThemeOnTheFly
authorErik Lumme <erik@vaadin.com>
Wed, 13 Sep 2017 07:48:29 +0000 (10:48 +0300)
committerErik Lumme <erik@vaadin.com>
Wed, 13 Sep 2017 07:48:29 +0000 (10:48 +0300)
documentation/articles/ChangingThemeOnTheFly.asciidoc [new file with mode: 0644]
documentation/articles/contents.asciidoc

diff --git a/documentation/articles/ChangingThemeOnTheFly.asciidoc b/documentation/articles/ChangingThemeOnTheFly.asciidoc
new file mode 100644 (file)
index 0000000..9f0722f
--- /dev/null
@@ -0,0 +1,35 @@
+[[changing-theme-on-the-fly]]
+Changing theme on the fly
+-------------------------
+
+Starting from Vaadin 7.3, you can change themes in the application
+without reloading the page. To do this, simply use the
+`UI.setTheme(String)` method.
+
+[source,java]
+....
+public class ThemeChangeUI extends UI {
+
+  private String[] themes = { "valo", "reindeer", "runo", "chameleon" };
+
+  @Override
+  protected void init(VaadinRequest request) {
+    ComboBox themePicker = new ComboBox("Theme", Arrays.asList(themes));
+    themePicker.setValue(getTheme());
+
+    themePicker.addValueChangeListener(new ValueChangeListener() {
+      @Override
+      public void valueChange(ValueChangeEvent event) {
+        String theme = (String) event.getProperty().getValue();
+        setTheme(theme);
+      }
+    });
+
+    setContent(themePicker);
+  }
+}
+....
+
+In this way, you can let your users choose the look of your application.
+The functionality also makes it easier to create applications that are
+branded for different customers.
index 90eb33e4425e44da7351b086543a80813dc16f17..dfc2790ffe418a1bff72c82e4c45cbfd32b42f02 100644 (file)
@@ -66,5 +66,6 @@ are great, too.
 - link:ValoThemeGettingStarted.asciidoc[Valo theme - Getting started]
 - link:UseTooltipsToClarifyFunctions.asciidoc[Use tooltips to clarify functions]
 - link:EnableAndDisableButtonsToIndicateState.asciidoc[Enable and disable buttons to indicate state]
+- link:ChangingThemeOnTheFly.asciidoc[Changing theme on the fly]
 - link:CreatingAUIExtension.asciidoc[Creating a UI extension]
 - link:CreatingAThemeUsingSass.asciidoc[Creating a theme using Sass]