Ejemplo n.º 1
0
 @Override
 public void init(final WindowBasedTextGUI textGUI) {
   final Window mainWindow = new BasicWindow("Choose test");
   Panel contentArea = new Panel();
   contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
   contentArea.addComponent(
       new Button(
           "Centered window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new CenteredWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new UndecoratedWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Centered window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new UndecoratedCenteredWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Full-screen window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new FullScreenWindow(true));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Full-screen window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new FullScreenWindow(false));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Expanded window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new ExpandedWindow(true));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Expanded window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new ExpandedWindow(false));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Close",
           new Runnable() {
             @Override
             public void run() {
               mainWindow.close();
             }
           }));
   mainWindow.setComponent(contentArea);
   textGUI.addWindow(mainWindow);
 }
Ejemplo n.º 2
0
  @Override
  public void init(WindowBasedTextGUI textGUI) {
    final BasicWindow window = new BasicWindow("Grid layout test");

    final Panel leftPanel = new Panel();

    Panel checkBoxPanel = new Panel();
    for (int i = 0; i < 4; i++) {
      CheckBox checkBox = new CheckBox("Checkbox #" + (i + 1));
      checkBoxPanel.addComponent(checkBox);
    }

    Panel textBoxPanel = new Panel();
    textBoxPanel.addComponent(
        Panels.horizontal(new Label("Normal:   "), new TextBox(new TerminalSize(12, 1), "Text")));
    textBoxPanel.addComponent(
        Panels.horizontal(
            new Label("Password: "******"Text").setMask('*')));

    Panel buttonPanel = new Panel();
    buttonPanel.addComponent(
        new Button(
            "Enable spacing",
            new Runnable() {
              @Override
              public void run() {
                LinearLayout layoutManager = (LinearLayout) leftPanel.getLayoutManager();
                layoutManager.setSpacing(layoutManager.getSpacing() == 0 ? 1 : 0);
              }
            }));

    leftPanel.addComponent(checkBoxPanel.withBorder(Borders.singleLine("CheckBoxes")));
    leftPanel.addComponent(textBoxPanel.withBorder(Borders.singleLine("TextBoxes")));
    leftPanel.addComponent(buttonPanel.withBorder(Borders.singleLine("Buttons")));

    Panel rightPanel = new Panel();
    textBoxPanel = new Panel();
    TextBox readOnlyTextArea = new TextBox(new TerminalSize(16, 8));
    readOnlyTextArea.setReadOnly(true);
    readOnlyTextArea.setText(TestUtils.downloadGPL());
    textBoxPanel.addComponent(readOnlyTextArea);
    rightPanel.addComponent(textBoxPanel.withBorder(Borders.singleLine("Read-only")));
    rightPanel.setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill));

    Panel contentArea = new Panel();
    contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
    contentArea.addComponent(Panels.horizontal(leftPanel, rightPanel));
    contentArea.addComponent(
        new Separator(Direction.HORIZONTAL)
            .setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill)));
    contentArea.addComponent(
        new Button(
                "OK",
                new Runnable() {
                  @Override
                  public void run() {
                    window.close();
                  }
                })
            .setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Center)));
    window.setComponent(contentArea);
    textGUI.addWindow(window);
  }