Many changes:
[fanfix.git] / src / jexer / demos / DemoMainWindow.java
index eef25e29aee47926195631f4ae7eea2bf517d22a..f1cbe2122cdbb54ee2088a3fbed979d805cecfdd 100644 (file)
@@ -29,6 +29,7 @@
 package jexer.demos;
 
 import java.io.*;
+import java.util.*;
 
 import jexer.*;
 import jexer.event.*;
@@ -67,6 +68,17 @@ public class DemoMainWindow extends TWindow {
      */
     TProgressBar progressBar;
 
+    /**
+     * Day of week label is updated with TSpinner clicks.
+     */
+    TLabel dayOfWeekLabel;
+
+    /**
+     * Day of week to demonstrate TSpinner.  Has to be at class scope so that
+     * it can be accessed by the anonymous TAction class.
+     */
+    GregorianCalendar calendar = new GregorianCalendar();
+
     // ------------------------------------------------------------------------
     // Constructors -----------------------------------------------------------
     // ------------------------------------------------------------------------
@@ -95,7 +107,7 @@ public class DemoMainWindow extends TWindow {
 
         // Add some widgets
         addLabel("Message Boxes", 1, row);
-        addButton("&MessageBoxes", 35, row,
+        TWidget first = addButton("&MessageBoxes", 35, row,
             new TAction() {
                 public void DO() {
                     new DemoMsgBoxWindow(getApplication());
@@ -114,7 +126,7 @@ public class DemoMainWindow extends TWindow {
         );
         row += 2;
 
-        addLabel("Text fields", 1, row);
+        addLabel("Text fields and calendar", 1, row);
         addButton("Field&s", 35, row,
             new TAction() {
                 public void DO() {
@@ -124,11 +136,11 @@ public class DemoMainWindow extends TWindow {
         );
         row += 2;
 
-        addLabel("Radio buttons and checkboxes", 1, row);
-        addButton("&Checkboxes", 35, row,
+        addLabel("Radio buttons, check and combobox", 1, row);
+        addButton("&CheckBoxes", 35, row,
             new TAction() {
                 public void DO() {
-                    new DemoCheckboxWindow(getApplication());
+                    new DemoCheckBoxWindow(getApplication());
                 }
             }
         );
@@ -214,6 +226,35 @@ public class DemoMainWindow extends TWindow {
             }
         );
 
+        dayOfWeekLabel = addLabel("Wednesday-", 35, row - 1, "tmenu", false);
+        dayOfWeekLabel.setLabel(String.format("%-10s",
+                calendar.getDisplayName(Calendar.DAY_OF_WEEK,
+                    Calendar.LONG, Locale.getDefault())));
+
+        addSpinner(35 + dayOfWeekLabel.getWidth(), row - 1,
+            new TAction() {
+                public void DO() {
+                    calendar.add(Calendar.DAY_OF_WEEK, 1);
+                    dayOfWeekLabel.setLabel(String.format("%-10s",
+                            calendar.getDisplayName(
+                            Calendar.DAY_OF_WEEK, Calendar.LONG,
+                            Locale.getDefault())));
+                }
+            },
+            new TAction() {
+                public void DO() {
+                    calendar.add(Calendar.DAY_OF_WEEK, -1);
+                    dayOfWeekLabel.setLabel(String.format("%-10s",
+                            calendar.getDisplayName(
+                            Calendar.DAY_OF_WEEK, Calendar.LONG,
+                            Locale.getDefault())));
+                }
+            }
+        );
+
+
+        activate(first);
+
         statusBar = newStatusBar("Demo Main Window");
         statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
         statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");