#63 setRequiresSelection
[nikiroo-utils.git] / src / jexer / demos / Demo7.java
CommitLineData
fc2af494
KL
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 */
29package jexer.demos;
30
31import java.util.ResourceBundle;
32
33import jexer.TApplication;
34import jexer.TPanel;
35import jexer.TText;
36import jexer.TWindow;
37import jexer.layout.BoxLayoutManager;
38
39/**
40 * This class shows off BoxLayout and TPanel.
41 */
42public class Demo7 {
43
44 /**
45 * Translated strings.
46 */
47 private static final ResourceBundle i18n = ResourceBundle.getBundle(Demo7.class.getName());
48
49 // ------------------------------------------------------------------------
50 // Demo7 ------------------------------------------------------------------
51 // ------------------------------------------------------------------------
52
53 /**
54 * Main entry point.
55 *
56 * @param args Command line arguments
57 */
58 public static void main(final String [] args) throws Exception {
59 // This demo will build everything "from the outside".
60
61 // Swing is the default backend on Windows unless explicitly
62 // overridden by jexer.Swing.
63 TApplication.BackendType backendType = TApplication.BackendType.XTERM;
64 if (System.getProperty("os.name").startsWith("Windows")) {
65 backendType = TApplication.BackendType.SWING;
66 }
67 if (System.getProperty("os.name").startsWith("Mac")) {
68 backendType = TApplication.BackendType.SWING;
69 }
70 if (System.getProperty("jexer.Swing") != null) {
71 if (System.getProperty("jexer.Swing", "false").equals("true")) {
72 backendType = TApplication.BackendType.SWING;
73 } else {
74 backendType = TApplication.BackendType.XTERM;
75 }
76 }
77 TApplication app = new TApplication(backendType);
78 app.addToolMenu();
79 app.addFileMenu();
80 TWindow window = new TWindow(app, i18n.getString("windowTitle"),
81 60, 22);
82 window.setLayoutManager(new BoxLayoutManager(window.getWidth() - 2,
83 window.getHeight() - 2, false));
84
85 TPanel right = window.addPanel(0, 0, 10, 10);
86 TPanel left = window.addPanel(0, 0, 10, 10);
87 right.setLayoutManager(new BoxLayoutManager(right.getWidth(),
88 right.getHeight(), true));
89 left.setLayoutManager(new BoxLayoutManager(left.getWidth(),
90 left.getHeight(), true));
91
92 left.addText("C1", 0, 0, left.getWidth(), left.getHeight());
93 left.addText("C2", 0, 0, left.getWidth(), left.getHeight());
94 left.addText("C3", 0, 0, left.getWidth(), left.getHeight());
95 right.addText("C4", 0, 0, right.getWidth(), right.getHeight());
96 right.addText("C5", 0, 0, right.getWidth(), right.getHeight());
97 right.addText("C6", 0, 0, right.getWidth(), right.getHeight());
98
99 app.run();
100 }
101
102}