46680519fc96c3b9571d873403902235d5674c81
2 * Jexer - Java Text User Interface
4 * The MIT License (MIT)
6 * Copyright (C) 2017 Kevin Lamonte
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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.
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
31 import java
.util
.ArrayList
;
32 import java
.util
.List
;
35 import static jexer
.TCommand
.*;
36 import static jexer
.TKeypress
.*;
39 * This window demonstates the TRadioGroup, TRadioButton, and TCheckBox
42 public class DemoCheckBoxWindow
extends TWindow
{
44 // ------------------------------------------------------------------------
45 // Variables --------------------------------------------------------------
46 // ------------------------------------------------------------------------
49 * Combo box. Has to be at class scope so that it can be accessed by the
50 * anonymous TAction class.
52 TComboBox comboBox
= null;
54 // ------------------------------------------------------------------------
55 // Constructors -----------------------------------------------------------
56 // ------------------------------------------------------------------------
61 * @param parent the main application
63 DemoCheckBoxWindow(final TApplication parent
) {
64 this(parent
, CENTERED
| RESIZABLE
);
70 * @param parent the main application
71 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
73 DemoCheckBoxWindow(final TApplication parent
, final int flags
) {
74 // Construct a demo window. X and Y don't matter because it will be
75 // centered on screen.
76 super(parent
, "Radiobuttons, CheckBoxes, and ComboBox",
82 addLabel("Check box example 1", 1, row
);
83 addCheckBox(35, row
++, "CheckBox 1", false);
84 addLabel("Check box example 2", 1, row
);
85 addCheckBox(35, row
++, "CheckBox 2", true);
88 TRadioGroup group
= addRadioGroup(1, row
, "Group 1");
89 group
.addRadioButton("Radio option 1");
90 group
.addRadioButton("Radio option 2");
91 group
.addRadioButton("Radio option 3");
93 List
<String
> comboValues
= new ArrayList
<String
>();
94 comboValues
.add("String 0");
95 comboValues
.add("String 1");
96 comboValues
.add("String 2");
97 comboValues
.add("String 3");
98 comboValues
.add("String 4");
99 comboValues
.add("String 5");
100 comboValues
.add("String 6");
101 comboValues
.add("String 7");
102 comboValues
.add("String 8");
103 comboValues
.add("String 9");
104 comboValues
.add("String 10");
106 comboBox
= addComboBox(35, row
, 12, comboValues
, 2, 6,
109 getApplication().messageBox("ComboBox",
110 "You selected the following value:\n" +
114 TMessageBox
.Type
.OK
);
119 addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
122 DemoCheckBoxWindow
.this.getApplication()
123 .closeWindow(DemoCheckBoxWindow
.this);
128 statusBar
= newStatusBar("Radiobuttons and checkboxes");
129 statusBar
.addShortcutKeypress(kbF1
, cmHelp
, "Help");
130 statusBar
.addShortcutKeypress(kbF2
, cmShell
, "Shell");
131 statusBar
.addShortcutKeypress(kbF3
, cmOpen
, "Open");
132 statusBar
.addShortcutKeypress(kbF10
, cmExit
, "Exit");