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(); }
public static void main(String[] args) { final GUIScreen guiScreen = new TestTerminalFactory(args).createGUIScreen(); guiScreen.getScreen().startScreen(); // Ensuring that a TextInputBox doesn't throw an exception if the description is // shorter than the title TextInputDialog.showTextInputBox(guiScreen, "Testing issue 53", "Issue 53", ""); guiScreen.getScreen().stopScreen(); }
/** * Will display a dialog prompting the user to select an action from a list. The label of each * action will be the result of calling toString() on each Action object. * * @param owner Screen to display the dialog on * @param title Title of the dialog * @param description Description label inside the dialog * @param itemWidth Width of the labels in the list, this will effectively set how wide the dialog * is * @param closeBeforeAction When an action in chosen, should the dialog be closed before the * action is executed? * @param actions List of actions inside the dialog */ public static void showActionListDialog( GUIScreen owner, String title, String description, int itemWidth, boolean closeBeforeAction, Action... actions) { // Autodetect width? if (itemWidth == 0) { showActionListDialog(owner, title, description, actions); return; } ActionListDialog actionListDialog = new ActionListDialog(title, description, itemWidth, closeBeforeAction); for (Action action : actions) actionListDialog.addAction(action.toString(), action); owner.showWindow(actionListDialog, GUIScreen.Position.CENTER); }
public static void show(final GUIScreen owner, final Player player) { owner.showWindow(new SeekDialog(player), GUIScreen.Position.CENTER); }