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;
import jexer.TWidget;
import jexer.TWindow;
import jexer.event.TCommandEvent;
+import jexer.layout.StretchLayoutManager;
import static jexer.TCommand.*;
import static jexer.TKeypress.*;
/**
* Timer that increments a number.
*/
- private TTimer timer;
+ private TTimer timer1;
+
+ /**
+ * Timer that increments a number.
+ */
+ private TTimer timer2;
/**
* Timer label is updated with timer ticks.
* Timer increment used by the timer loop. Has to be at class scope so
* that it can be accessed by the anonymous TAction class.
*/
- int timerI = 0;
+ int timer1I = 0;
/**
- * Progress bar used by the timer loop. Has to be at class scope so that
- * it can be accessed by the anonymous TAction class.
+ * Timer increment used by the timer loop. Has to be at class scope so
+ * that it can be accessed by the anonymous TAction class.
*/
- TProgressBar progressBar;
+ int timer2I = 0;
/**
- * Day of week label is updated with TSpinner clicks.
+ * Progress bar used by the timer loop. Has to be at class scope so that
+ * it can be accessed by the anonymous TAction class.
*/
- TLabel dayOfWeekLabel;
+ TProgressBar progressBar1;
/**
- * Day of week to demonstrate TSpinner. Has to be at class scope so that
+ * Progress bar used by the timer loop. Has to be at class scope so that
* it can be accessed by the anonymous TAction class.
*/
- GregorianCalendar calendar = new GregorianCalendar();
+ TProgressBar progressBar2;
// ------------------------------------------------------------------------
// Constructors -----------------------------------------------------------
private DemoMainWindow(final TApplication parent, final int flags) {
// Construct a demo window. X and Y don't matter because it will be
// centered on screen.
- super(parent, i18n.getString("windowTitle"), 0, 0, 64, 25, flags);
+ super(parent, i18n.getString("windowTitle"), 0, 0, 64, 23, flags);
+
+ setLayoutManager(new StretchLayoutManager(getWidth() - 2,
+ getHeight() - 2));
int row = 1;
addButton(i18n.getString("ttableButton1"), 35, row,
new TAction() {
public void DO() {
- // TODO
+ new DemoTableWindow(getApplication(),
+ i18n.getString("tableWidgetDemo"));
}
}
);
}
}
);
- row += 2;
- progressBar = addProgressBar(1, row, 22, 0);
+ row = 15;
+ progressBar1 = addProgressBar(48, row, 12, 0);
row++;
- timerLabel = addLabel(i18n.getString("timerLabel"), 1, row);
- timer = getApplication().addTimer(250, true,
+ timerLabel = addLabel(i18n.getString("timerLabel"), 48, row);
+ timer1 = getApplication().addTimer(250, true,
new TAction() {
public void DO() {
timerLabel.setLabel(String.format(i18n.
- getString("timerText"), timerI));
+ getString("timerText"), timer1I));
timerLabel.setWidth(timerLabel.getLabel().length());
- if (timerI < 100) {
- timerI++;
+ if (timer1I < 100) {
+ timer1I++;
} else {
- timer.setRecurring(false);
+ timer1.setRecurring(false);
}
- progressBar.setValue(timerI);
+ progressBar1.setValue(timer1I);
}
}
);
- 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,
+ row += 2;
+ progressBar2 = addProgressBar(48, row, 12, 0);
+ progressBar2.setLeftBorderChar('\u255e');
+ progressBar2.setRightBorderChar('\u2561');
+ progressBar2.setCompletedChar('\u2592');
+ progressBar2.setRemainingChar('\u2550');
+ row++;
+ timer2 = getApplication().addTimer(125, true,
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())));
+ if (timer2I < 100) {
+ timer2I++;
+ } else {
+ timer2.setRecurring(false);
+ }
+ progressBar2.setValue(timer2I);
}
- },
+ }
+ );
+
+ /*
+ 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())));
+ try {
+ throw new RuntimeException("FUBAR'd!");
+ } catch (Exception e) {
+ new jexer.TExceptionDialog(getApplication(), e);
+ }
}
}
);
-
+ */
activate(first);
*/
@Override
public void onClose() {
- getApplication().removeTimer(timer);
+ getApplication().removeTimer(timer1);
+ getApplication().removeTimer(timer2);
}
/**