コード例 #1
0
ファイル: Message.java プロジェクト: andy-mueller/jcurses
  /**
   * The constructor
   *
   * @param title the message's title
   * @param text the message's text
   * @param buttonLabel the label on the message's button
   */
  public Message(String title, String text, String buttonLabel) {
    super(getWidth(text, title) + 4, getHeight(text) + 7, true, title);

    DefaultLayoutManager manager = new DefaultLayoutManager();
    manager.bindToContainer(getRootPanel());

    _label = new Label(text);
    _button = new Button(buttonLabel);
    _title = title;

    _button.addListener(this);

    manager.addWidget(
        _label,
        0,
        0,
        getWidth(text, _title) + 2,
        getHeight(text) + 2,
        WidgetsConstants.ALIGNMENT_CENTER,
        WidgetsConstants.ALIGNMENT_CENTER);

    manager.addWidget(
        _button,
        0,
        getHeight(text) + 2,
        getWidth(text, _title) + 2,
        5,
        WidgetsConstants.ALIGNMENT_CENTER,
        WidgetsConstants.ALIGNMENT_CENTER);
  }
コード例 #2
0
ファイル: FileDialog.java プロジェクト: Phionx/BrownSquad
  /**
   * The constructor
   *
   * @param x the x coordinate of the dialog window's top left corner
   * @param y the y coordinate of the dialog window's top left corner
   * @title dialog's title
   */
  public FileDialog(int x, int y, int width, int height, String title) {
    super(x, y, width, height, true, title);

    _directories = new List();
    _directories.setSelectable(false);
    _directories.setTitle("Directories");
    _directories.addListener(this);
    _files = new List();
    _files.setSelectable(false);
    _files.setTitle("Files");
    _files.addListener(this);
    _fileLabel = new Label("File: ");
    _filterLabel = new Label("Filter: ");
    _fileField = new TextField();
    _fileField.setText(getCurrentFileContent());
    _filterField = new FilterTextField(this);
    _okButton = new Button("OK");
    _okButton.addListener(this);
    _cancelButton = new Button("Cancel");
    _cancelButton.addListener(this);

    Panel topPanel = new Panel();
    GridLayoutManager topManager = new GridLayoutManager(2, 1);
    topPanel.setLayoutManager(topManager);
    topManager.addWidget(_directories, 0, 0, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);
    topManager.addWidget(_files, 1, 0, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);

    Panel bottomPanel = new Panel();
    GridLayoutManager bottomManager = new GridLayoutManager(4, 4);
    bottomPanel.setLayoutManager(bottomManager);
    bottomManager.addWidget(_fileLabel, 0, 0, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_RIGHT);
    bottomManager.addWidget(_filterLabel, 0, 2, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_RIGHT);
    bottomManager.addWidget(_fileField, 1, 0, 2, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);
    bottomManager.addWidget(_filterField, 1, 2, 2, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);
    bottomManager.addWidget(_okButton, 3, 0, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);
    bottomManager.addWidget(_cancelButton, 3, 2, 1, 1, ALIGNMENT_CENTER, ALIGNMENT_CENTER);

    DefaultLayoutManager manager = (DefaultLayoutManager) getRootPanel().getLayoutManager();

    manager.addWidget(topPanel, 0, 0, width - 2, height - 6, ALIGNMENT_CENTER, ALIGNMENT_CENTER);
    manager.addWidget(bottomPanel, 0, height - 6, width - 2, 4, ALIGNMENT_CENTER, ALIGNMENT_CENTER);

    fillListWidgets(getCurrentDirectory());
  }