network socket support, Swing blink/reverse
[fanfix.git] / src / jexer / demos / DemoApplication.java
1 /*
2 * Jexer - Java Text User Interface
3 *
4 * License: LGPLv3 or later
5 *
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.
9 *
10 * Copyright (C) 2015 Kevin Lamonte
11 *
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.
16 *
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.
21 *
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
26 * 02110-1301 USA
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
30 */
31 package jexer.demos;
32
33 import java.io.*;
34
35 import jexer.*;
36 import jexer.event.*;
37 import jexer.menu.*;
38
39 /**
40 * The demo application itself.
41 */
42 class DemoApplication extends TApplication {
43
44 /**
45 * Add all the widgets of the demo.
46 */
47 private void addAllWidgets() {
48 new DemoMainWindow(this);
49
50 // Add the menus
51 addFileMenu();
52 addEditMenu();
53
54 TMenu demoMenu = addMenu("&Demo");
55 TMenuItem item = demoMenu.addItem(2000, "&Checkable");
56 item.setCheckable(true);
57 item = demoMenu.addItem(2001, "Disabled");
58 item.setEnabled(false);
59 item = demoMenu.addItem(2002, "&Normal");
60 TSubMenu subMenu = demoMenu.addSubMenu("Sub-&Menu");
61 item = demoMenu.addItem(2010, "N&ormal A&&D");
62
63 item = subMenu.addItem(2000, "&Checkable (sub)");
64 item.setCheckable(true);
65 item = subMenu.addItem(2001, "Disabled (sub)");
66 item.setEnabled(false);
67 item = subMenu.addItem(2002, "&Normal (sub)");
68
69 subMenu = subMenu.addSubMenu("Sub-&Menu");
70 item = subMenu.addItem(2000, "&Checkable (sub)");
71 item.setCheckable(true);
72 item = subMenu.addItem(2001, "Disabled (sub)");
73 item.setEnabled(false);
74 item = subMenu.addItem(2002, "&Normal (sub)");
75
76 addWindowMenu();
77 }
78
79 /**
80 * Public constructor.
81 *
82 * @param input an InputStream connected to the remote user, or null for
83 * System.in. If System.in is used, then on non-Windows systems it will
84 * be put in raw mode; shutdown() will (blindly!) put System.in in cooked
85 * mode. input is always converted to a Reader with UTF-8 encoding.
86 * @param output an OutputStream connected to the remote user, or null
87 * for System.out. output is always converted to a Writer with UTF-8
88 * encoding.
89 * @throws UnsupportedEncodingException if an exception is thrown when
90 * creating the InputStreamReader
91 */
92 public DemoApplication(final InputStream input,
93 final OutputStream output) throws UnsupportedEncodingException {
94 super(input, output);
95 addAllWidgets();
96 }
97
98 /**
99 * Public constructor.
100 *
101 * @param backendType one of the TApplication.BackendType values
102 * @throws Exception if TApplication can't instantiate the Backend.
103 */
104 public DemoApplication(BackendType backendType) throws Exception {
105 super(backendType);
106 addAllWidgets();
107 }
108 }