TSplitPane initial
[nikiroo-utils.git] / src / jexer / demos / Demo8.java
1 /*
2 * Jexer - Java Text User Interface
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (C) 2019 Kevin Lamonte
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 */
29 package jexer.demos;
30
31 import java.util.ResourceBundle;
32
33 import jexer.TApplication;
34 import jexer.TPanel;
35 import jexer.TSplitPane;
36 import jexer.TText;
37 import jexer.TWindow;
38 import jexer.layout.BoxLayoutManager;
39 import jexer.menu.TMenu;
40
41 /**
42 * This class shows off TSplitPane.
43 */
44 public class Demo8 {
45
46 /**
47 * Translated strings.
48 */
49 private static final ResourceBundle i18n = ResourceBundle.getBundle(Demo8.class.getName());
50
51 // ------------------------------------------------------------------------
52 // Constants --------------------------------------------------------------
53 // ------------------------------------------------------------------------
54
55 private static String TEXT =
56 "This is an example of a reflowable text field. Some example text follows.\n" +
57 "\n" +
58 "Notice that some menu items should be disabled when this window has focus.\n" +
59 "\n" +
60 "This library implements a text-based windowing system loosely " +
61 "reminiscent of Borland's [Turbo " +
62 "Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those " +
63 "wishing to use the actual C++ Turbo Vision library, see [Sergio " +
64 "Sigala's updated version](http://tvision.sourceforge.net/) that runs " +
65 "on many more platforms.\n" +
66 "\n" +
67 "This library is licensed MIT. See the file LICENSE for the full license " +
68 "for the details.\n";
69
70 // ------------------------------------------------------------------------
71 // Demo8 ------------------------------------------------------------------
72 // ------------------------------------------------------------------------
73
74 /**
75 * Main entry point.
76 *
77 * @param args Command line arguments
78 */
79 public static void main(final String [] args) throws Exception {
80 // This demo will build everything "from the outside".
81
82 // Swing is the default backend on Windows unless explicitly
83 // overridden by jexer.Swing.
84 TApplication.BackendType backendType = TApplication.BackendType.XTERM;
85 if (System.getProperty("os.name").startsWith("Windows")) {
86 backendType = TApplication.BackendType.SWING;
87 }
88 if (System.getProperty("os.name").startsWith("Mac")) {
89 backendType = TApplication.BackendType.SWING;
90 }
91 if (System.getProperty("jexer.Swing") != null) {
92 if (System.getProperty("jexer.Swing", "false").equals("true")) {
93 backendType = TApplication.BackendType.SWING;
94 } else {
95 backendType = TApplication.BackendType.XTERM;
96 }
97 }
98
99 // For this demo, let's disable the status bar.
100 System.setProperty("jexer.hideStatusBar", "true");
101
102 TApplication app = new TApplication(backendType);
103 app.addToolMenu();
104 app.addFileMenu();
105 TWindow window = new TWindow(app, i18n.getString("windowTitle"),
106 60, 22);
107
108 TMenu paneMenu = app.addMenu(i18n.getString("paneMenu"));
109 paneMenu.addDefaultItem(TMenu.MID_SPLIT_VERTICAL, true);
110 paneMenu.addDefaultItem(TMenu.MID_SPLIT_HORIZONTAL, true);
111
112 TSplitPane pane = window.addSplitPane(0, 0, window.getWidth() - 2,
113 window.getHeight() - 2, true);
114
115 pane.setLeft(new TText(null, TEXT, 0, 0, 10, 10));
116 pane.setRight(new TText(null, TEXT, 0, 0, 10, 10));
117
118 app.run();
119 }
120
121 }