X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDemoMainWindow.java;h=8f77448b29f45c65cd67e52c38268e0564ad1e0d;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=1c8b4fbc154c3cf4d799990d09767fbaaf980f58;hpb=d8dc8aea32a07a0653933700f1abadc7776b013f;p=fanfix.git diff --git a/src/jexer/demos/DemoMainWindow.java b/src/jexer/demos/DemoMainWindow.java index 1c8b4fb..8f77448 100644 --- a/src/jexer/demos/DemoMainWindow.java +++ b/src/jexer/demos/DemoMainWindow.java @@ -66,7 +66,12 @@ public class DemoMainWindow extends TWindow { /** * 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. @@ -77,13 +82,25 @@ public class DemoMainWindow extends TWindow { * 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; + + /** + * 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 timer2I = 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. */ - TProgressBar progressBar; + TProgressBar progressBar1; + + /** + * Progress bar used by the timer loop. Has to be at class scope so that + * it can be accessed by the anonymous TAction class. + */ + TProgressBar progressBar2; // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- @@ -109,7 +126,8 @@ public class DemoMainWindow extends TWindow { // centered on screen. super(parent, i18n.getString("windowTitle"), 0, 0, 64, 23, flags); - setLayoutManager(new StretchLayoutManager(getWidth(), getHeight())); + setLayoutManager(new StretchLayoutManager(getWidth() - 2, + getHeight() - 2)); int row = 1; @@ -234,22 +252,43 @@ public class DemoMainWindow extends TWindow { ); row = 15; - progressBar = addProgressBar(48, row, 12, 0); + progressBar1 = addProgressBar(48, row, 12, 0); row++; timerLabel = addLabel(i18n.getString("timerLabel"), 48, row); - timer = getApplication().addTimer(250, true, + 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 { + timer1.setRecurring(false); + } + progressBar1.setValue(timer1I); + } + } + ); + + 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() { + if (timer2I < 100) { + timer2I++; } else { - timer.setRecurring(false); + timer2.setRecurring(false); } - progressBar.setValue(timerI); + progressBar2.setValue(timer2I); } } ); @@ -292,7 +331,8 @@ public class DemoMainWindow extends TWindow { */ @Override public void onClose() { - getApplication().removeTimer(timer); + getApplication().removeTimer(timer1); + getApplication().removeTimer(timer2); } /**