hidden mouse pointer support
[fanfix.git] / src / jexer / demos / DemoCheckBoxWindow.java
CommitLineData
e3dfbd23
KL
1/*
2 * Jexer - Java Text User Interface
3 *
e16dda65 4 * The MIT License (MIT)
e3dfbd23 5 *
a69ed767 6 * Copyright (C) 2019 Kevin Lamonte
e3dfbd23 7 *
e16dda65
KL
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
e3dfbd23 14 *
e16dda65
KL
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
e3dfbd23 17 *
e16dda65
KL
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
e3dfbd23
KL
25 *
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
27 * @version 1
28 */
29package jexer.demos;
30
a69ed767 31import java.text.MessageFormat;
051e2913
KL
32import java.util.ArrayList;
33import java.util.List;
a69ed767
KL
34import java.util.ResourceBundle;
35
36import jexer.TAction;
37import jexer.TApplication;
38import jexer.TComboBox;
39import jexer.TMessageBox;
40import jexer.TRadioGroup;
41import jexer.TWindow;
2ce6dab2
KL
42import static jexer.TCommand.*;
43import static jexer.TKeypress.*;
e3dfbd23
KL
44
45/**
051e2913 46 * This window demonstates the TRadioGroup, TRadioButton, and TCheckBox
e3dfbd23
KL
47 * widgets.
48 */
051e2913
KL
49public class DemoCheckBoxWindow extends TWindow {
50
a69ed767
KL
51 /**
52 * Translated strings.
53 */
54 private static final ResourceBundle i18n = ResourceBundle.getBundle(DemoCheckBoxWindow.class.getName());
55
051e2913
KL
56 // ------------------------------------------------------------------------
57 // Variables --------------------------------------------------------------
58 // ------------------------------------------------------------------------
59
60 /**
61 * Combo box. Has to be at class scope so that it can be accessed by the
62 * anonymous TAction class.
63 */
64 TComboBox comboBox = null;
e3dfbd23 65
43ad7b6c
KL
66 // ------------------------------------------------------------------------
67 // Constructors -----------------------------------------------------------
68 // ------------------------------------------------------------------------
69
e3dfbd23
KL
70 /**
71 * Constructor.
72 *
73 * @param parent the main application
74 */
051e2913 75 DemoCheckBoxWindow(final TApplication parent) {
e3dfbd23
KL
76 this(parent, CENTERED | RESIZABLE);
77 }
78
79 /**
80 * Constructor.
81 *
82 * @param parent the main application
83 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
84 */
051e2913 85 DemoCheckBoxWindow(final TApplication parent, final int flags) {
e3dfbd23
KL
86 // Construct a demo window. X and Y don't matter because it will be
87 // centered on screen.
a69ed767 88 super(parent, i18n.getString("windowTitle"), 0, 0, 60, 17, flags);
e3dfbd23
KL
89
90 int row = 1;
91
92 // Add some widgets
a69ed767
KL
93 addLabel(i18n.getString("checkBoxLabel1"), 1, row);
94 addCheckBox(35, row++, i18n.getString("checkBoxText1"), false);
95 addLabel(i18n.getString("checkBoxLabel2"), 1, row);
96 addCheckBox(35, row++, i18n.getString("checkBoxText2"), true);
e3dfbd23
KL
97 row += 2;
98
a69ed767
KL
99 TRadioGroup group = addRadioGroup(1, row,
100 i18n.getString("radioGroupTitle"));
101 group.addRadioButton(i18n.getString("radioOption1"));
102 group.addRadioButton(i18n.getString("radioOption2"));
103 group.addRadioButton(i18n.getString("radioOption3"));
e3dfbd23 104
051e2913 105 List<String> comboValues = new ArrayList<String>();
a69ed767
KL
106 comboValues.add(i18n.getString("comboBoxString0"));
107 comboValues.add(i18n.getString("comboBoxString1"));
108 comboValues.add(i18n.getString("comboBoxString2"));
109 comboValues.add(i18n.getString("comboBoxString3"));
110 comboValues.add(i18n.getString("comboBoxString4"));
111 comboValues.add(i18n.getString("comboBoxString5"));
112 comboValues.add(i18n.getString("comboBoxString6"));
113 comboValues.add(i18n.getString("comboBoxString7"));
114 comboValues.add(i18n.getString("comboBoxString8"));
115 comboValues.add(i18n.getString("comboBoxString9"));
116 comboValues.add(i18n.getString("comboBoxString10"));
051e2913
KL
117
118 comboBox = addComboBox(35, row, 12, comboValues, 2, 6,
119 new TAction() {
120 public void DO() {
a69ed767
KL
121 getApplication().messageBox(i18n.getString("messageBoxTitle"),
122 MessageFormat.format(i18n.getString("messageBoxPrompt"),
123 comboBox.getText()),
051e2913
KL
124 TMessageBox.Type.OK);
125 }
126 }
127 );
128
a69ed767
KL
129 addButton(i18n.getString("closeWindow"),
130 (getWidth() - 14) / 2, getHeight() - 4,
e3dfbd23
KL
131 new TAction() {
132 public void DO() {
051e2913
KL
133 DemoCheckBoxWindow.this.getApplication()
134 .closeWindow(DemoCheckBoxWindow.this);
e3dfbd23
KL
135 }
136 }
137 );
2ce6dab2 138
a69ed767
KL
139 statusBar = newStatusBar(i18n.getString("statusBar"));
140 statusBar.addShortcutKeypress(kbF1, cmHelp,
141 i18n.getString("statusBarHelp"));
142 statusBar.addShortcutKeypress(kbF2, cmShell,
143 i18n.getString("statusBarShell"));
144 statusBar.addShortcutKeypress(kbF3, cmOpen,
145 i18n.getString("statusBarOpen"));
146 statusBar.addShortcutKeypress(kbF10, cmExit,
147 i18n.getString("statusBarExit"));
e3dfbd23
KL
148 }
149
150}