com.googlecode.lanterna.screen.Screen Java Examples

The following examples show how to use com.googlecode.lanterna.screen.Screen. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawRectangle.java    From lanterna with GNU Lesser General Public License v3.0 7 votes vote down vote up
public static void main(String[] args) throws IOException {
	Terminal terminal = new DefaultTerminalFactory().createTerminal();
	Screen screen = new TerminalScreen(terminal);

	TextGraphics tGraphics = screen.newTextGraphics();

	screen.startScreen();
	screen.clear();

	tGraphics.drawRectangle(
		new TerminalPosition(3,3), new TerminalSize(10,10), '*');
	screen.refresh();

	screen.readInput();
	screen.stopScreen();
}
 
Example #2
Source File: TerminalTta3Orchestrator.java    From pen-test-automation with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    // Setup terminal and screen layers
    TerminalSize size = new TerminalSize(80,50);  // unsure how to do this.
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    /// ???.setPreferredSize(new TerminalSize(20, 5))

    try {
        screen.startScreen();
        TerminalTta3Orchestrator terminalTta3Orchestrator = new TerminalTta3Orchestrator(screen);
        terminalTta3Orchestrator.start();
    } finally {
        screen.stopScreen();
        terminal.close();
    }
}
 
Example #3
Source File: Issue452.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    try (Screen screen = new DefaultTerminalFactory().setTelnetPort(23000)
            .setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE_DRAG_MOVE).setInitialTerminalSize(new TerminalSize(100, 100))
            .createScreen()) {
        screen.startScreen();
        WindowBasedTextGUI gui = new MultiWindowTextGUI(screen);
        Window window = new BasicWindow("Issue452");
        Panel content = new Panel(new GridLayout(GRID_WIDTH));
        GridLayout gridLayout = (GridLayout) content.getLayoutManager();
        gridLayout.setVerticalSpacing(1);
        addInteractableComponentsToContent(content);
        addMenuBar(window);
        window.setComponent(content);
        gui.addWindowAndWait(window);
    }
}
 
Example #4
Source File: Issue384.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    final Screen screen = new DefaultTerminalFactory().createScreen();
    screen.startScreen();
    final MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen);
    final Window window = new BasicWindow("Table container test");
    window.setHints(Collections.singletonList(Window.Hint.FIXED_SIZE));
    window.setFixedSize(new TerminalSize(60, 14));

    final Table<String> table = new Table<>("Column", "Expanded Column", "Column");
    table.setCellSelection(true);
    table.setVisibleRows(10);
    final DefaultTableRenderer<String> tableRenderer = new DefaultTableRenderer<>();
    tableRenderer.setExpandableColumns(Collections.singletonList(1));
    table.setRenderer(tableRenderer);

    final TableModel<String> model = table.getTableModel();
    for(int i = 1; i <= 20; i++) {
        String cellLabel = "Row" + i;
        model.addRow(cellLabel, cellLabel, cellLabel);
    }

    Panel buttonPanel = new Panel();
    buttonPanel.setLayoutManager(new LinearLayout(Direction.HORIZONTAL));
    buttonPanel.addComponent(new Button("Change Expandable Columns", () -> showExpandableColumnsEditor(textGUI, tableRenderer)));
    buttonPanel.addComponent(new Button("Close", window::close));

    window.setComponent(Panels.vertical(
            table.withBorder(Borders.singleLineBevel("Table")),
            buttonPanel));
    table.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill));
    textGUI.addWindow(window);
    textGUI.waitForWindowToClose(window);
    screen.stopScreen();
}
 
Example #5
Source File: Issue334.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    // Create panel to hold components
    Panel panel = new Panel();
    panel.setLayoutManager(new GridLayout(1));
    panel.addComponent(new Label(""));

    // Create gui and start gui
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));

    // Create window to hold the panel
    final BasicWindow window = new BasicWindow();
    window.setComponent(Panels.vertical(panel));
    window.setCloseWindowWithEscape(true);

    gui.addWindowAndWait(window);
    screen.stopScreen();
    terminal.close();
}
 
Example #6
Source File: Issue95.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException, IOException {
    SwingTerminalFrame terminal = new SwingTerminalFrame(TerminalEmulatorAutoCloseTrigger.CloseOnExitPrivateMode);
    terminal.setCursorVisible(false);

    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();
    
    terminal.setTitle("Freedom: An arena-battle roguelike");
    terminal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    terminal.setResizable(false);
    terminal.setVisible(true);

    while(screen.pollInput() == null) {
        if(screen.doResizeIfNecessary() != null) {
            screen.refresh();
        }
        Thread.sleep(100);
    }
    screen.stopScreen();
}
 
Example #7
Source File: TestBase.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
void run(String[] args) throws IOException, InterruptedException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();
    MultiWindowTextGUI textGUI = createTextGUI(screen);
    String theme = extractTheme(args);
    if(theme != null) {
        textGUI.setTheme(LanternaThemes.getRegisteredTheme(theme));
    }
    textGUI.setBlockingIO(false);
    textGUI.setEOFWhenNoWindows(true);
    //noinspection ResultOfMethodCallIgnored
    textGUI.isEOFWhenNoWindows();   //No meaning, just to silence IntelliJ:s "is never used" alert

    try {
        init(textGUI);
        AsynchronousTextGUIThread guiThread = (AsynchronousTextGUIThread)textGUI.getGUIThread();
        guiThread.start();
        afterGUIThreadStarted(textGUI);
        guiThread.waitForStop();
    }
    finally {
        screen.stopScreen();
    }
}
 
Example #8
Source File: MultiButtonTest.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();
    MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen);
    textGUI.setEOFWhenNoWindows(true);
    try {
        final BasicWindow window = new BasicWindow("Button test");
        Panel contentArea = new Panel();
        contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
        contentArea.addComponent(new Button(""));
        contentArea.addComponent(new Button("TRE"));
        contentArea.addComponent(new Button("Button"));
        contentArea.addComponent(new Button("Another button"));
        contentArea.addComponent(new EmptySpace(new TerminalSize(5, 1)));
        //contentArea.addComponent(new Button("Here is a\nmulti-line\ntext segment that is using \\n"));
        contentArea.addComponent(new Button("OK", window::close));

        window.setComponent(contentArea);
        textGUI.addWindowAndWait(window);
    }
    finally {
        screen.stopScreen();
    }
}
 
Example #9
Source File: Issue358.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();
    MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));

    String title = "Issue358";

    int nbColumns = 5;
    final Window window = new BasicWindow(title);

    final GridLayout layoutManager = new GridLayout(nbColumns);
    layoutManager.setVerticalSpacing(0);
    layoutManager.setHorizontalSpacing(1);
    final Panel contentPanel = new Panel(layoutManager);
    contentPanel.addComponent(
            new EmptySpace(TextColor.ANSI.CYAN).setLayoutData(GridLayout.createLayoutData(GridLayout.Alignment.CENTER, GridLayout.Alignment.CENTER, false, false,3, 1)));
    window.setComponent(contentPanel);
    textGUI.addWindowAndWait(window);
}
 
Example #10
Source File: OutputString.java    From lanterna with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
	Terminal terminal = new DefaultTerminalFactory().createTerminal();
	Screen screen = new TerminalScreen(terminal);

	String s = "Hello World!";
	TextGraphics tGraphics = screen.newTextGraphics();

	screen.startScreen();
	screen.clear();

	tGraphics.putString(10, 10, s);
	screen.refresh();

	screen.readInput();
	screen.stopScreen();
}
 
Example #11
Source File: FancyChooser.java    From apdu4j with MIT License 6 votes vote down vote up
private FancyChooser(Terminal terminal, Screen screen, CardTerminals monitorObject, List<CardTerminal> terminals) {
    if (monitorObject != null)
        monitor = new MonitorThread(monitorObject);
    else monitor = null;
    this.terminal = terminal;
    this.screen = screen;
    gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
    this.initialList = terminals;
    // Create UI elements
    mainWindow = new BasicWindow(" apdu4j ");
    mainWindow.setCloseWindowWithEscape(true);
    mainWindow.setHints(Arrays.asList(Window.Hint.FIT_TERMINAL_WINDOW, Window.Hint.CENTERED));

    mainPanel = new Panel();
    mainPanel.setLayoutManager(new BorderLayout());
    mainPanel.setLayoutManager(new LinearLayout(Direction.VERTICAL));
    mainActions = new ActionListBox();
    mainActions.setLayoutData(BorderLayout.Location.CENTER);
    mainPanel.addComponent(mainActions);
    mainPanel.addComponent(new EmptySpace(new TerminalSize(0, 1)));
    quitButton = new Button("Cancel and quit", () -> mainWindow.close());
    quitButton.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.End));
    mainPanel.addComponent(quitButton);
    //mainPanel.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.End));
    mainWindow.setComponent(mainPanel);
}
 
Example #12
Source File: Issue313.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    BasicWindow window = new BasicWindow();
    window.setTitle("Hello World");

    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
    gui.addWindowAndWait(window);
}
 
Example #13
Source File: Issue261.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    // 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 gui and start gui
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));

    // Create window to hold the panel
    BasicWindow window = new BasicWindow();
    window.setFixedSize(new TerminalSize(500, 700));
    window.setComponent(panel);

    gui.addWindowAndWait(window);
}
 
Example #14
Source File: Issue376.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String... args) throws IOException {
    Screen screen = new DefaultTerminalFactory().createScreen();
    screen.startScreen();
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
    Window window = new LabelWithTabWindow();
    gui.addWindow(window);
    gui.waitForWindowToClose(window);
    screen.stopScreen();
}
 
Example #15
Source File: Issue212.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    final Table<String> table = new Table<>("Column 1", "Column 2",
            "Column 3");
    table.getTableModel().addRow("1", "2", "3");
    table.getTableModel().addRow("1", "2", "3");
    table.getTableModel().addRow("1", "2", "3");
    table.getTableModel().addRow("1", "2", "3");
    table.getTableModel().addRow("1", "2", "3");
    table.setSelectAction(() -> {
        List<String> data = table.getTableModel().getRow(
                table.getSelectedRow());
        for (String aData : data) {
            System.out.println(aData);
        }
    });

    Window win = new BasicWindow();
    win.setComponent(table);

    DefaultTerminalFactory factory = new DefaultTerminalFactory();
    Terminal terminal = factory.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(win);

    screen.stopScreen();
}
 
Example #16
Source File: Issue155.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String... args) throws IOException {
    Terminal term = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(term);
    WindowManager windowManager = new DefaultWindowManager();
    Component background = new EmptySpace(TextColor.ANSI.DEFAULT);
    final WindowBasedTextGUI gui = new MultiWindowTextGUI(screen, windowManager, background);
    screen.startScreen();
    gui.addWindowAndWait(new BasicWindow("Issue155") {{
        setComponent(createUi(gui, this));
    }});
    screen.stopScreen();
}
 
Example #17
Source File: OutputChar.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
	Terminal terminal = new DefaultTerminalFactory().createTerminal();
	Screen screen = new TerminalScreen(terminal);

	screen.startScreen();
	screen.clear();

	screen.setCharacter(10, 10, new TextCharacter('*'));
	screen.refresh();

	screen.readInput();
	screen.stopScreen();
}
 
Example #18
Source File: Issue374.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    final BasicWindow window = new BasicWindow("FocusTraversalTest");
    window.setHints(Collections.singletonList(Window.Hint.FULL_SCREEN));
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);

    Panel mainPanel = new Panel(new LinearLayout());
    window.setComponent(mainPanel);

    Button disabledInBorder1 = new Button("disabledB1");
    disabledInBorder1.setEnabled(false);
    mainPanel.addComponent(disabledInBorder1.withBorder(Borders.singleLine("border")));

    Button first = new Button("enabled");
    mainPanel.addComponent(first);

    Button disabled = new Button("disabled");
    disabled.setEnabled(false);
    mainPanel.addComponent(disabled);

    Button disabledInBorder2 = new Button("disabledB2");
    disabledInBorder2.setEnabled(false);
    mainPanel.addComponent(disabledInBorder2.withBorder(Borders.singleLine("border")));

    Button anotherFocusable = new Button("focusable");
    mainPanel.addComponent(anotherFocusable);

    mainPanel.addComponent(new Button("Button"));

    first.takeFocus();
    gui.addWindowAndWait(window);
}
 
Example #19
Source File: Issue216.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    // 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 Label("Table"));
    final Table<String> table = new Table<>("Test");
    final TableModel<String> tableModel = table.getTableModel();
    tableModel.addRow("hi");
    panel.addComponent(table);

    panel.addComponent(new EmptySpace(new TerminalSize(0,0))); // Empty space underneath labels
    panel.addComponent(new Button("Submit", () -> {
        tableModel.addRow("haiiii");
        //table.invalidate();
    }));

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

    // Create gui and start gui
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
    gui.addWindowAndWait(window);
}
 
Example #20
Source File: Issue254.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    // Now resize the window to the smallest possible size allowed by the window manager
    // Then quickly make it bigger by grabbing the bottom right corner
}
 
Example #21
Source File: FullScreenTextGUITest.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException {
    Screen screen = new TestTerminalFactory(args).setInitialTerminalSize(new TerminalSize(80, 25)).createScreen();
    screen.startScreen();

    final AtomicBoolean stop = new AtomicBoolean(false);
    MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen);
    textGUI.addListener((textGUI1, key) -> {
        if(key.getKeyType() == KeyType.Escape) {
            stop.set(true);
            return true;
        }
        return false;
    });
    try {
        textGUI.getBackgroundPane().setComponent(new BIOS());
        while(!stop.get()) {
            if(!textGUI.getGUIThread().processEventsAndUpdate()) {
                Thread.sleep(1);
            }
        }
    }
    catch (EOFException ignore) {
        // Terminal closed
    }
    finally {
        screen.stopScreen();
    }
}
 
Example #22
Source File: MultiWindowTextGUI.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@code MultiWindowTextGUI} that uses the specified {@code Screen} as the backend for all drawing
 * operations. The background area of the GUI will be a solid color, depending on theme (default is blue). This
 * constructor allows you control the threading model for the UI.
 * @param guiThreadFactory Factory implementation to use when creating the {@code TextGUIThread}
 * @param screen Screen to use as the backend for drawing operations
 */
public MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen) {
    this(guiThreadFactory,
            screen,
            new DefaultWindowManager(),
            null,
            new GUIBackdrop());
}
 
Example #23
Source File: LineWrappingLabelTest.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected MultiWindowTextGUI createTextGUI(Screen screen) {
    return new MultiWindowTextGUI(
            new SeparateTextGUIThread.Factory(),
            screen,
            new MyWindowManager(),
            new WindowShadowRenderer(),
            new EmptySpace(TextColor.ANSI.BLUE));
}
 
Example #24
Source File: Issue150.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String... args) throws IOException {
    Terminal term = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(term);
    WindowManager windowManager = new DefaultWindowManager();
    Component background = new EmptySpace(TextColor.ANSI.DEFAULT);
    final WindowBasedTextGUI gui = new MultiWindowTextGUI(screen, windowManager, background);
    screen.startScreen();
    gui.addWindowAndWait(new BasicWindow("Issue150") {{
        setComponent(createUi());
    }});
    screen.stopScreen();
}
 
Example #25
Source File: Issue387.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        Screen screen = new DefaultTerminalFactory().createScreen();
        screen.startScreen();

        Window window = new BasicWindow();

        Table<String> table = new Table<>("Column");
        table.setVisibleRows(3);

        table.getTableModel().addRow("row 1");
        table.getTableModel().addRow("row 2");
        table.getTableModel().addRow("row 3");
        table.getTableModel().addRow("row 4");
        table.getTableModel().addRow("row 5");
        table.getTableModel().addRow("row 6");
        table.getTableModel().addRow("row 7");

        Panel panel = new Panel();
        panel.addComponent(new TextBox());
        panel.addComponent(new EmptySpace(new TerminalSize(15, 1)));
        panel.addComponent(table);
        panel.addComponent(new EmptySpace(new TerminalSize(15, 1)));
        panel.addComponent(new TextBox());

        window.setComponent(panel);

        MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
        gui.addWindowAndWait(window);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #26
Source File: AbstractTextGUI.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor for {@code AbstractTextGUI} that requires a {@code Screen} and a factory for creating the GUI thread
 * @param textGUIThreadFactory Factory class to use for creating the {@code TextGUIThread} class
 * @param screen What underlying {@code Screen} to use for this text GUI
 */
protected AbstractTextGUI(TextGUIThreadFactory textGUIThreadFactory, Screen screen) {
    if(screen == null) {
        throw new IllegalArgumentException("Creating a TextGUI requires an underlying Screen");
    }
    this.screen = screen;
    this.listeners = new CopyOnWriteArrayList<>();
    this.blockingIO = false;
    this.dirty = false;
    this.guiTheme = LanternaThemes.getDefaultTheme();
    this.textGUIThread = textGUIThreadFactory.createTextGUIThread(this);
}
 
Example #27
Source File: Issue221.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {

        // Setup terminal and screen layers
        Terminal terminal = new DefaultTerminalFactory().createTerminal();
        Screen screen = new TerminalScreen(terminal);
        screen.startScreen();

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

        panel.addComponent(new Label("The List"));
        RadioBoxList<String> box = new RadioBoxList<>();
        box.addItem("Item 1");
        box.addItem("Item 2");
        box.addItem("Item 3");
        box.addListener((selected, previous) -> System.out.println("Selected Index: " + selected + ", previous: " + previous));

        panel.addComponent(box);

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

        // Create gui and start gui
        MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
        gui.addWindowAndWait(window);
    }
 
Example #28
Source File: Issue380.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    Screen screen = new DefaultTerminalFactory().createScreen();
    screen.startScreen();
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
    Window window = new GridWindowWithTwoLargeComponents();
    window.setHints(Collections.singletonList(Window.Hint.EXPANDED));
    gui.addWindow(window);
    gui.waitForWindowToClose(window);
    screen.stopScreen();
}
 
Example #29
Source File: Issue460.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    screen.startScreen();

    final BasicWindow window1 = new BasicWindow();
    Panel contentPanel = new Panel(new GridLayout(1));
    contentPanel.addComponent(new Label("VERTICAL"), GridLayout.createLayoutData(
            GridLayout.Alignment.CENTER,
            GridLayout.Alignment.CENTER,
            true,
            true,
            1,
            4
    ));
    contentPanel.addComponent(new Button("Close", new Runnable() {
        @Override
        public void run() {
            window1.close();
        }
    }), GridLayout.createHorizontallyFilledLayoutData(2));
    window1.setComponent(contentPanel);

    // Create gui and start gui
    MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
    gui.addWindowAndWait(window1);
    screen.stopScreen();
}
 
Example #30
Source File: FancyChooser.java    From apdu4j with MIT License 4 votes vote down vote up
public static FancyChooser forTerminals(List<CardTerminal> terminals) throws IOException {
    Terminal terminal = new DefaultTerminalFactory().createTerminal();
    Screen screen = new TerminalScreen(terminal);
    return new FancyChooser(terminal, screen, null, terminals);
}