a56da43760e3b38176f90e4dc33d034530b70d4a
2 * Jexer - Java Text User Interface
4 * The MIT License (MIT)
6 * Copyright (C) 2016 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]
34 * This window demonstates the TMessageBox and TInputBox widgets.
36 public class DemoMsgBoxWindow
extends TWindow
{
41 * @param parent the main application
43 DemoMsgBoxWindow(final TApplication parent
) {
44 this(parent
, TWindow
.CENTERED
| TWindow
.RESIZABLE
);
50 * @param parent the main application
51 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
53 DemoMsgBoxWindow(final TApplication parent
, final int flags
) {
54 // Construct a demo window. X and Y don't matter because it
55 // will be centered on screen.
56 super(parent
, "Message Boxes", 0, 0, 60, 15, flags
);
61 addLabel("Default OK message box", 1, row
);
62 addButton("Open O&K MB", 35, row
,
65 getApplication().messageBox("OK MessageBox",
66 "This is an example of a OK MessageBox. This is the\n" +
67 "default MessageBox.\n" +
69 "Note that the MessageBox text can span multiple\n" +
72 "The default result (if someone hits the top-left\n" +
73 "close button) is OK.\n",
80 addLabel("OK/Cancel message box", 1, row
);
81 addButton("O&pen OKC MB", 35, row
,
84 getApplication().messageBox("OK/Cancel MessageBox",
85 "This is an example of a OK/Cancel MessageBox.\n" +
87 "Note that the MessageBox text can span multiple\n" +
90 "The default result (if someone hits the top-left\n" +
91 "close button) is CANCEL.\n",
92 TMessageBox
.Type
.OKCANCEL
);
98 addLabel("Yes/No message box", 1, row
);
99 addButton("Open &YN MB", 35, row
,
102 getApplication().messageBox("Yes/No MessageBox",
103 "This is an example of a Yes/No MessageBox.\n" +
105 "Note that the MessageBox text can span multiple\n" +
108 "The default result (if someone hits the top-left\n" +
109 "close button) is NO.\n",
110 TMessageBox
.Type
.YESNO
);
116 addLabel("Yes/No/Cancel message box", 1, row
);
117 addButton("Ope&n YNC MB", 35, row
,
120 getApplication().messageBox("Yes/No/Cancel MessageBox",
121 "This is an example of a Yes/No/Cancel MessageBox.\n" +
123 "Note that the MessageBox text can span multiple\n" +
126 "The default result (if someone hits the top-left\n" +
127 "close button) is CANCEL.\n",
128 TMessageBox
.Type
.YESNOCANCEL
);
134 addLabel("Input box", 1, row
);
135 addButton("Open &input box", 35, row
,
138 TInputBox in
= getApplication().inputBox("Input Box",
139 "This is an example of an InputBox.\n" +
141 "Note that the InputBox text can span multiple\n" +
144 getApplication().messageBox("Your InputBox Answer",
145 "You entered: " + in
.getText());
150 addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
153 getApplication().closeWindow(DemoMsgBoxWindow
.this);