public static void main(String[] args) throws IOException { final GUIScreen textGUI = new TestTerminalFactory(args).createGUIScreen(); textGUI.getScreen().startScreen(); textGUI.setBackgroundRenderer(new DefaultBackgroundRenderer("GUI Test")); final Window mainWindow = new Window("Testing issue 7"); mainWindow.addComponent(new EmptySpace(16, 1)); Panel panel = new Panel("Panel"); panel.setBorder(new Border.Standard()); panel.addComponent(new Label("Label 1")); panel.addComponent(new Label("Label 2")); panel.addComponent(new Label("Label 3")); mainWindow.addComponent(panel); mainWindow.addComponent(new EmptySpace(16, 1)); mainWindow.addComponent( new Button( "Close", new Action() { public void doAction() { mainWindow.close(); } })); textGUI.showWindow(mainWindow, GUIScreen.Position.CENTER); textGUI.getScreen().stopScreen(); }
public static void main(String[] args) throws IOException { final GUIScreen guiScreen = new TestTerminalFactory(args).createGUIScreen(); guiScreen.getScreen().startScreen(); guiScreen.setBackgroundRenderer(new DefaultBackgroundRenderer("GUI Test")); final Window mainWindow = new Window("Window with BorderLayout"); final Panel borderLayoutPanel = new Panel("BorderLayout"); borderLayoutPanel.setLayoutManager(new BorderLayout()); final Component topComponent = new MockComponent('T', new TerminalSize(50, 3)); final Component centerComponent = new MockComponent('C', new TerminalSize(5, 5)); final Component leftComponent = new MockComponent('L', new TerminalSize(6, 3)); final Component rightComponent = new MockComponent('R', new TerminalSize(6, 3)); final Component bottomComponent = new MockComponent('B', new TerminalSize(50, 3)); borderLayoutPanel.addComponent(topComponent, BorderLayout.TOP); borderLayoutPanel.addComponent(centerComponent, BorderLayout.CENTER); borderLayoutPanel.addComponent(bottomComponent, BorderLayout.BOTTOM); borderLayoutPanel.addComponent(leftComponent, BorderLayout.LEFT); borderLayoutPanel.addComponent(rightComponent, BorderLayout.RIGHT); mainWindow.addComponent(borderLayoutPanel); Panel buttonPanel = new Panel(Panel.Orientation.HORIZONTAL); buttonPanel.addComponent(new EmptySpace(), LinearLayout.GROWS_HORIZONTALLY); Button toggleButton = new Button( "Toggle components", new Action() { @Override public void doAction() throws IOException { ActionListDialog.showActionListDialog( guiScreen, "Toggle component", "Choose a component to show/hide", new ToggleAction("Top", borderLayoutPanel, topComponent, BorderLayout.TOP), new ToggleAction("Left", borderLayoutPanel, leftComponent, BorderLayout.LEFT), new ToggleAction( "Center", borderLayoutPanel, centerComponent, BorderLayout.CENTER), new ToggleAction( "Right", borderLayoutPanel, rightComponent, BorderLayout.RIGHT), new ToggleAction( "Bottom", borderLayoutPanel, bottomComponent, BorderLayout.BOTTOM)); } }); buttonPanel.addComponent(toggleButton); Button closeButton = new Button( "Close", new Action() { @Override public void doAction() { mainWindow.close(); } }); buttonPanel.addComponent(closeButton); mainWindow.addComponent(buttonPanel, LinearLayout.GROWS_HORIZONTALLY); guiScreen.showWindow(mainWindow, GUIScreen.Position.FULL_SCREEN); guiScreen.getScreen().stopScreen(); }