2 * Jexer - Java Text User Interface
4 * The MIT License (MIT)
6 * Copyright (C) 2017 Kevin Lamonte
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:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
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.
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
39 * The demo application itself.
41 public class DesktopDemoApplication
extends TApplication
{
44 * Add all the widgets of the demo.
46 private void addAllWidgets() {
54 final DesktopDemo desktop
= new DesktopDemo(this);
57 desktop
.addButton("&Remove HATCH", 2, 5,
60 desktop
.drawHatch
= false;
64 desktop
.addButton("&Show HATCH", 2, 8,
67 desktop
.drawHatch
= true;
76 * @param menu menu event
77 * @return if true, the event was processed and should not be passed onto
81 public boolean onMenu(final TMenuEvent menu
) {
83 if (menu
.getId() == TMenu
.MID_OPEN_FILE
) {
85 String filename
= fileOpenBox(".");
86 if (filename
!= null) {
88 File file
= new File(filename
);
89 StringBuilder fileContents
= new StringBuilder();
90 Scanner scanner
= new Scanner(file
);
91 String EOL
= System
.getProperty("line.separator");
94 while (scanner
.hasNextLine()) {
95 fileContents
.append(scanner
.nextLine() + EOL
);
97 new DemoTextWindow(this, filename
,
98 fileContents
.toString());
102 } catch (IOException e
) {
106 } catch (IOException e
) {
111 return super.onMenu(menu
);
115 * Public constructor.
117 * @param backendType one of the TApplication.BackendType values
118 * @throws Exception if TApplication can't instantiate the Backend.
120 public DesktopDemoApplication(final BackendType backendType
) throws Exception
{
123 getBackend().setTitle("Jexer Demo Application");