Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1004410 // Lanterna Test [Text Mode UI, WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 507K of libraries. Click here for Pure Java version (904L/7K/23K).

!752

lib 1004408

import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.gui2.*;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.GridLayout;
import com.googlecode.lanterna.gui2.Button;
import com.googlecode.lanterna.screen.Screen;
import com.googlecode.lanterna.screen.TerminalScreen;
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
import com.googlecode.lanterna.terminal.Terminal;

p {
  // Create panel to hold components
  Panel panel = new Panel();
  panel.setLayoutManager(new GridLayout(2));

  panel.addComponent(new Label("Forename"));
  panel.addComponent(new TextBox());

  panel.addComponent(new Label("Surname"));
  panel.addComponent(new TextBox());

  panel.addComponent(new EmptySpace(new TerminalSize(0,0))); // Empty space underneath labels
  panel.addComponent(new Button("Submit"));

  // Create window to hold the panel
  BasicWindow window = new BasicWindow();
  window.setComponent(panel);

  // Setup terminal and screen layers
  Terminal terminal = new DefaultTerminalFactory().createTerminal();
  Screen screen = new TerminalScreen(terminal);
  screen.startScreen();
  
  // Create gui and start gui
  MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
  gui.addWindowAndWait(window);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004410
Snippet name: Lanterna Test [Text Mode UI, WORKS]
Eternal ID of this version: #1004410/2
Text MD5: 9904179c461d731322eee35f09c88974
Transpilation MD5: 5cce811d65310b47fe3d886d0a3b1c4d
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-12 03:31:43
Source code size: 1481 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 692 / 730
Version history: 1 change(s)
Referenced in: #1011950 - Shortened Lanterna Demo to 1 Line