X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fdemos%2FDemoCheckBoxWindow.java;h=fda7bd7a15ae6567eee7a21d17b090cc46648c4f;hb=12b90437b5f22c2ae6e9b9b14c3b62b60f6143e5;hp=46680519fc96c3b9571d873403902235d5674c81;hpb=051e29138b18fb4b731a72f8727475b10e4c74e4;p=nikiroo-utils.git diff --git a/src/jexer/demos/DemoCheckBoxWindow.java b/src/jexer/demos/DemoCheckBoxWindow.java index 4668051..fda7bd7 100644 --- a/src/jexer/demos/DemoCheckBoxWindow.java +++ b/src/jexer/demos/DemoCheckBoxWindow.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,10 +28,18 @@ */ package jexer.demos; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; - -import jexer.*; +import java.util.ResourceBundle; + +import jexer.TAction; +import jexer.TApplication; +import jexer.TComboBox; +import jexer.TMessageBox; +import jexer.TRadioGroup; +import jexer.TWindow; +import jexer.layout.StretchLayoutManager; import static jexer.TCommand.*; import static jexer.TKeypress.*; @@ -41,6 +49,11 @@ import static jexer.TKeypress.*; */ public class DemoCheckBoxWindow extends TWindow { + /** + * Translated strings. + */ + private static final ResourceBundle i18n = ResourceBundle.getBundle(DemoCheckBoxWindow.class.getName()); + // ------------------------------------------------------------------------ // Variables -------------------------------------------------------------- // ------------------------------------------------------------------------ @@ -73,50 +86,52 @@ public class DemoCheckBoxWindow extends TWindow { DemoCheckBoxWindow(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, "Radiobuttons, CheckBoxes, and ComboBox", - 0, 0, 60, 17, flags); + super(parent, i18n.getString("windowTitle"), 0, 0, 60, 17, flags); + + setLayoutManager(new StretchLayoutManager(getWidth() - 2, + getHeight() - 2)); int row = 1; // Add some widgets - addLabel("Check box example 1", 1, row); - addCheckBox(35, row++, "CheckBox 1", false); - addLabel("Check box example 2", 1, row); - addCheckBox(35, row++, "CheckBox 2", true); + addLabel(i18n.getString("checkBoxLabel1"), 1, row); + addCheckBox(35, row++, i18n.getString("checkBoxText1"), false); + addLabel(i18n.getString("checkBoxLabel2"), 1, row); + addCheckBox(35, row++, i18n.getString("checkBoxText2"), true); row += 2; - TRadioGroup group = addRadioGroup(1, row, "Group 1"); - group.addRadioButton("Radio option 1"); - group.addRadioButton("Radio option 2"); - group.addRadioButton("Radio option 3"); + TRadioGroup group = addRadioGroup(1, row, + i18n.getString("radioGroupTitle")); + group.addRadioButton(i18n.getString("radioOption1")); + group.addRadioButton(i18n.getString("radioOption2")); + group.addRadioButton(i18n.getString("radioOption3")); List comboValues = new ArrayList(); - comboValues.add("String 0"); - comboValues.add("String 1"); - comboValues.add("String 2"); - comboValues.add("String 3"); - comboValues.add("String 4"); - comboValues.add("String 5"); - comboValues.add("String 6"); - comboValues.add("String 7"); - comboValues.add("String 8"); - comboValues.add("String 9"); - comboValues.add("String 10"); + comboValues.add(i18n.getString("comboBoxString0")); + comboValues.add(i18n.getString("comboBoxString1")); + comboValues.add(i18n.getString("comboBoxString2")); + comboValues.add(i18n.getString("comboBoxString3")); + comboValues.add(i18n.getString("comboBoxString4")); + comboValues.add(i18n.getString("comboBoxString5")); + comboValues.add(i18n.getString("comboBoxString6")); + comboValues.add(i18n.getString("comboBoxString7")); + comboValues.add(i18n.getString("comboBoxString8")); + comboValues.add(i18n.getString("comboBoxString9")); + comboValues.add(i18n.getString("comboBoxString10")); comboBox = addComboBox(35, row, 12, comboValues, 2, 6, new TAction() { public void DO() { - getApplication().messageBox("ComboBox", - "You selected the following value:\n" + - "\n" + - comboBox.getText() + - "\n", + getApplication().messageBox(i18n.getString("messageBoxTitle"), + MessageFormat.format(i18n.getString("messageBoxPrompt"), + comboBox.getText()), TMessageBox.Type.OK); } } ); - addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4, + addButton(i18n.getString("closeWindow"), + (getWidth() - 14) / 2, getHeight() - 4, new TAction() { public void DO() { DemoCheckBoxWindow.this.getApplication() @@ -125,11 +140,15 @@ public class DemoCheckBoxWindow extends TWindow { } ); - statusBar = newStatusBar("Radiobuttons and checkboxes"); - statusBar.addShortcutKeypress(kbF1, cmHelp, "Help"); - statusBar.addShortcutKeypress(kbF2, cmShell, "Shell"); - statusBar.addShortcutKeypress(kbF3, cmOpen, "Open"); - statusBar.addShortcutKeypress(kbF10, cmExit, "Exit"); + statusBar = newStatusBar(i18n.getString("statusBar")); + statusBar.addShortcutKeypress(kbF1, cmHelp, + i18n.getString("statusBarHelp")); + statusBar.addShortcutKeypress(kbF2, cmShell, + i18n.getString("statusBarShell")); + statusBar.addShortcutKeypress(kbF3, cmOpen, + i18n.getString("statusBarOpen")); + statusBar.addShortcutKeypress(kbF10, cmExit, + i18n.getString("statusBarExit")); } }