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]
32 import static jexer
.TCommand
.*;
33 import static jexer
.TKeypress
.*;
36 * This window demonstates the TMessageBox and TInputBox widgets.
38 public class DemoMsgBoxWindow
extends TWindow
{
40 // ------------------------------------------------------------------------
41 // Constructors -----------------------------------------------------------
42 // ------------------------------------------------------------------------
47 * @param parent the main application
49 DemoMsgBoxWindow(final TApplication parent
) {
50 this(parent
, TWindow
.CENTERED
| TWindow
.RESIZABLE
);
56 * @param parent the main application
57 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
59 DemoMsgBoxWindow(final TApplication parent
, final int flags
) {
60 // Construct a demo window. X and Y don't matter because it
61 // will be centered on screen.
62 super(parent
, "Message Boxes", 0, 0, 64, 18, flags
);
67 addLabel("Default OK message box", 1, row
);
68 addButton("Open O&K MB", 35, row
,
71 getApplication().messageBox("OK MessageBox",
72 "This is an example of a OK MessageBox. This is the\n" +
73 "default MessageBox.\n" +
75 "Note that the MessageBox text can span multiple\n" +
78 "The default result (if someone hits the top-left\n" +
79 "close button) is OK.\n",
86 addLabel("OK/Cancel message box", 1, row
);
87 addButton("O&pen OKC MB", 35, row
,
90 getApplication().messageBox("OK/Cancel MessageBox",
91 "This is an example of a OK/Cancel MessageBox.\n" +
93 "Note that the MessageBox text can span multiple\n" +
96 "The default result (if someone hits the top-left\n" +
97 "close button) is CANCEL.\n",
98 TMessageBox
.Type
.OKCANCEL
);
104 addLabel("Yes/No message box", 1, row
);
105 addButton("Open &YN MB", 35, row
,
108 getApplication().messageBox("Yes/No MessageBox",
109 "This is an example of a Yes/No MessageBox.\n" +
111 "Note that the MessageBox text can span multiple\n" +
114 "The default result (if someone hits the top-left\n" +
115 "close button) is NO.\n",
116 TMessageBox
.Type
.YESNO
);
122 addLabel("Yes/No/Cancel message box", 1, row
);
123 addButton("Ope&n YNC MB", 35, row
,
126 getApplication().messageBox("Yes/No/Cancel MessageBox",
127 "This is an example of a Yes/No/Cancel MessageBox.\n" +
129 "Note that the MessageBox text can span multiple\n" +
132 "The default result (if someone hits the top-left\n" +
133 "close button) is CANCEL.\n",
134 TMessageBox
.Type
.YESNOCANCEL
);
140 addLabel("Input box 1", 1, row
);
141 addButton("Open &input box", 35, row
,
144 TInputBox in
= getApplication().inputBox("Input Box",
145 "This is an example of an InputBox.\n" +
147 "Note that the InputBox text can span multiple\n" +
150 getApplication().messageBox("Your InputBox Answer",
151 "You entered: " + in
.getText());
157 addLabel("Input box 2", 1, row
);
158 addButton("Cance&llable input box", 35, row
,
161 TInputBox in
= getApplication().inputBox("Input Box",
162 "This is an example of an InputBox.\n" +
164 "Note that the InputBox text can span multiple\n" +
166 "This one has both OK and Cancel buttons.\n",
167 "some input text", TInputBox
.Type
.OKCANCEL
);
168 getApplication().messageBox("Your InputBox Answer",
169 "You entered: " + in
.getText() + " and pressed " +
175 addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
178 getApplication().closeWindow(DemoMsgBoxWindow
.this);
183 statusBar
= newStatusBar("Message boxes");
184 statusBar
.addShortcutKeypress(kbF1
, cmHelp
, "Help");
185 statusBar
.addShortcutKeypress(kbF2
, cmShell
, "Shell");
186 statusBar
.addShortcutKeypress(kbF3
, cmOpen
, "Open");
187 statusBar
.addShortcutKeypress(kbF10
, cmExit
, "Exit");