More PMD warnings
[fanfix.git] / src / jexer / demos / DemoTextFieldWindow.java
CommitLineData
2ce6dab2
KL
1/*
2 * Jexer - Java Text User Interface
3 *
4 * The MIT License (MIT)
5 *
a2018e99 6 * Copyright (C) 2017 Kevin Lamonte
2ce6dab2
KL
7 *
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:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
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.
25 *
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
27 * @version 1
28 */
29package jexer.demos;
30
31import jexer.*;
32import static jexer.TCommand.*;
33import static jexer.TKeypress.*;
34
35/**
36 * This window demonstates the TField and TPasswordField widgets.
37 */
38public class DemoTextFieldWindow extends TWindow {
39
43ad7b6c
KL
40 // ------------------------------------------------------------------------
41 // Constructors -----------------------------------------------------------
42 // ------------------------------------------------------------------------
43
2ce6dab2
KL
44 /**
45 * Constructor.
46 *
47 * @param parent the main application
48 */
49 DemoTextFieldWindow(final TApplication parent) {
50 this(parent, TWindow.CENTERED | TWindow.RESIZABLE);
51 }
52
53 /**
54 * Constructor.
55 *
56 * @param parent the main application
57 * @param flags bitmask of MODAL, CENTERED, or RESIZABLE
58 */
59 DemoTextFieldWindow(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, "Text Fields", 0, 0, 60, 10, flags);
63
64 int row = 1;
65
66 addLabel("Variable-width text field:", 1, row);
67 addField(35, row++, 15, false, "Field text");
68 addLabel("Fixed-width text field:", 1, row);
69 addField(35, row++, 15, true);
70 addLabel("Variable-width password:", 1, row);
71 addPasswordField(35, row++, 15, false);
72 addLabel("Fixed-width password:", 1, row);
73 addPasswordField(35, row++, 15, true, "hunter2");
24489803
KL
74 addLabel("Very long text field:", 1, row);
75 TField selected = addField(35, row++, 40, false,
76 "Very very long field text that should be outside the window");
2ce6dab2
KL
77 row += 1;
78
79 addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
80 new TAction() {
81 public void DO() {
82 getApplication().closeWindow(DemoTextFieldWindow.this);
83 }
84 }
85 );
86
24489803
KL
87 activate(selected);
88
2ce6dab2
KL
89 statusBar = newStatusBar("Text fields");
90 statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
91 statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");
92 statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
93 statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
94 }
43ad7b6c 95
2ce6dab2 96}