2 * Jexer - Java Text User Interface
4 * License: LGPLv3 or later
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
10 * Copyright (C) 2015 Kevin Lamonte
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
38 * This window demonstates the TMessageBox and TInputBox widgets.
40 public class DemoMsgBoxWindow
extends TWindow
{
45 * @param parent the main application
47 DemoMsgBoxWindow(final TApplication parent
) {
48 this(parent
, TWindow
.CENTERED
| TWindow
.RESIZABLE
);
54 * @param parent the main application
55 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
57 DemoMsgBoxWindow(final TApplication parent
, final int flags
) {
58 // Construct a demo window. X and Y don't matter because it
59 // will be centered on screen.
60 super(parent
, "Message Boxes", 0, 0, 60, 15, flags
);
65 addLabel("Default OK message box", 1, row
);
66 addButton("Open O&K MB", 35, row
,
69 getApplication().messageBox("OK MessageBox",
70 "This is an example of a OK MessageBox. This is the\n" +
71 "default MessageBox.\n" +
73 "Note that the MessageBox text can span multiple\n" +
76 "The default result (if someone hits the top-left\n" +
77 "close button) is OK.\n",
84 addLabel("OK/Cancel message box", 1, row
);
85 addButton("O&pen OKC MB", 35, row
,
88 getApplication().messageBox("OK/Cancel MessageBox",
89 "This is an example of a OK/Cancel MessageBox.\n" +
91 "Note that the MessageBox text can span multiple\n" +
94 "The default result (if someone hits the top-left\n" +
95 "close button) is CANCEL.\n",
96 TMessageBox
.Type
.OKCANCEL
);
102 addLabel("Yes/No message box", 1, row
);
103 addButton("Open &YN MB", 35, row
,
106 getApplication().messageBox("Yes/No MessageBox",
107 "This is an example of a Yes/No MessageBox.\n" +
109 "Note that the MessageBox text can span multiple\n" +
112 "The default result (if someone hits the top-left\n" +
113 "close button) is NO.\n",
114 TMessageBox
.Type
.YESNO
);
120 addLabel("Yes/No/Cancel message box", 1, row
);
121 addButton("Ope&n YNC MB", 35, row
,
124 getApplication().messageBox("Yes/No/Cancel MessageBox",
125 "This is an example of a Yes/No/Cancel MessageBox.\n" +
127 "Note that the MessageBox text can span multiple\n" +
130 "The default result (if someone hits the top-left\n" +
131 "close button) is CANCEL.\n",
132 TMessageBox
.Type
.YESNOCANCEL
);
138 addLabel("Input box", 1, row
);
139 addButton("Open &input box", 35, row
,
142 TInputBox in
= getApplication().inputBox("Input Box",
143 "This is an example of an InputBox.\n" +
145 "Note that the InputBox text can span multiple\n" +
148 getApplication().messageBox("Your InputBox Answer",
149 "You entered: " + in
.getText());
154 addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
157 getApplication().closeWindow(DemoMsgBoxWindow
.this);