#46 BoxLayoutManager working
[fanfix.git] / src / jexer / demos / DemoMainWindow.java
index 1ae35f0b7dab058f42fdef8e7b6946241d00b6fe..0be7088556e959b2c64c9d725e316ebbfb1b7321 100644 (file)
@@ -31,9 +31,6 @@ package jexer.demos;
 import java.io.File;
 import java.io.IOException;
 import java.text.MessageFormat;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Locale;
 import java.util.ResourceBundle;
 
 import jexer.TAction;
@@ -42,10 +39,12 @@ import jexer.TEditColorThemeWindow;
 import jexer.TEditorWindow;
 import jexer.TLabel;
 import jexer.TProgressBar;
+import jexer.TTableWindow;
 import jexer.TTimer;
 import jexer.TWidget;
 import jexer.TWindow;
 import jexer.event.TCommandEvent;
+import jexer.layout.StretchLayoutManager;
 import static jexer.TCommand.*;
 import static jexer.TKeypress.*;
 
@@ -86,17 +85,6 @@ 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 -----------------------------------------------------------
     // ------------------------------------------------------------------------
@@ -121,6 +109,9 @@ public class DemoMainWindow extends TWindow {
         // centered on screen.
         super(parent, i18n.getString("windowTitle"), 0, 0, 64, 23, flags);
 
+        setLayoutManager(new StretchLayoutManager(getWidth() - 2,
+                getHeight() - 2));
+
         int row = 1;
 
         // Add some widgets
@@ -191,6 +182,25 @@ public class DemoMainWindow extends TWindow {
         );
         row += 2;
 
+        addLabel(i18n.getString("ttableLabel"), 1, row);
+        addButton(i18n.getString("ttableButton1"), 35, row,
+            new TAction() {
+                public void DO() {
+                    new DemoTableWindow(getApplication(),
+                        i18n.getString("tableWidgetDemo"));
+                }
+            }
+        );
+        addButton(i18n.getString("ttableButton2"), 48, row,
+            new TAction() {
+                public void DO() {
+                    new TTableWindow(getApplication(),
+                        i18n.getString("tableDemo"));
+                }
+            }
+        );
+        row += 2;
+
         addLabel(i18n.getString("treeViewLabel"), 1, row);
         addButton(i18n.getString("treeViewButton"), 35, row,
             new TAction() {
@@ -223,11 +233,11 @@ public class DemoMainWindow extends TWindow {
                 }
             }
         );
-        row += 2;
 
-        progressBar = addProgressBar(1, row, 22, 0);
+        row = 15;
+        progressBar = addProgressBar(48, row, 12, 0);
         row++;
-        timerLabel = addLabel(i18n.getString("timerLabel"), 1, row);
+        timerLabel = addLabel(i18n.getString("timerLabel"), 48, row);
         timer = getApplication().addTimer(250, true,
             new TAction() {
 
@@ -245,32 +255,19 @@ 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,
+        /*
+        addButton("Exception", 35, row + 3,
             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())));
+                    try {
+                        throw new RuntimeException("FUBAR'd!");
+                    } catch (Exception e) {
+                        new jexer.TExceptionDialog(getApplication(), e);
+                    }
                 }
             }
         );
-
+         */
 
         activate(first);