Example #1
0
  /**
   * Creates a new word editor form.
   *
   * @param parentWindow The parent window.
   * @param actionListener The action-listener.
   */
  public WordEditorForm(WindowPane parentWindow, ActionListener actionListener) {
    this.parentWindow = parentWindow;
    this.actionListener = actionListener;

    Column borderCol = new Column();
    borderCol.setBorder(new Border(1, Color.BLACK, Border.STYLE_INSET));

    Grid grid = new Grid(1);
    grid.setRowHeight(0, new Extent(parentWindow.getHeight().getValue() - 160));
    grid.setRowHeight(1, new Extent(30));

    column = new Column();
    column.setInsets(new Insets(10, 20, 0, 0));
    column.setCellSpacing(new Extent(10));
    GridLayoutData gridLayout = new GridLayoutData();
    gridLayout.setAlignment(new Alignment(Alignment.LEFT, Alignment.TOP));
    column.setLayoutData(gridLayout);
    grid.add(column);

    explanationRow = new Row();
    column.add(explanationRow);

    Row footerRow = new Row();
    footerRow.setInsets(new Insets(10, 0, 0, 0));
    String l = "* " + LocaleResources.getString("preditor_wordeditor_required");
    footerRow.add(new Label(l, Font.ITALIC, 11));
    grid.add(footerRow);

    buttonBar = new Row();
    buttonBar.setAlignment(new Alignment(Alignment.RIGHT, Alignment.CENTER));
    buttonBar.setInsets(new Insets(10, 10, 10, 10));
    buttonBar.setCellSpacing(new Extent(5));
    grid.add(buttonBar);

    addButton("general_action_ok");
    addButton("general_action_cancel");

    borderCol.add(grid);
    add(borderCol);
  }
Example #2
0
 /**
  * Adds a new row to the form.
  *
  * @param labelText The text for the label shown on the left hand side of the component.
  * @param formElement The component, i.e. a text field.
  * @param explanation An explanation text shown under the component.
  * @param required Defines whether the component should be marked as required.
  */
 public void addRow(
     String labelText, Component formElement, String explanation, boolean required) {
   Grid grid = new Grid(3);
   grid.setInsets(new Insets(0, 0, 5, 0));
   grid.setColumnWidth(0, new Extent(140));
   grid.add(new SolidLabel(labelText, Font.ITALIC));
   formElements.add(formElement);
   if (formElement instanceof TextField) {
     TextField tf = (TextField) formElement;
     tf.setWidth(new Extent(parentWindow.getWidth().getValue() - 223));
     tf.setActionCommand("OK");
     tf.addActionListener(this);
   }
   grid.add(formElement);
   if (required) {
     requiredFormElements.add(formElement);
     grid.add(new Label("*", Font.ITALIC, 11));
   } else {
     grid.add(new Label());
   }
   grid.add(new Label());
   grid.add(new Label(explanation, Font.ITALIC, 11));
   column.add(grid);
 }