Beispiel #1
0
  public void setupDBFields(String dbname) throws Exception {

    viewPane.setLayout(null);
    Dimension dimView = sp.getSize();
    int height = 0, width = 50;
    viewPane.removeAll();
    db = new DBF(dbname);
    setTitle(dbname);

    gb = new GridBagLayout();
    gbc = new GridBagConstraints();
    viewPane.setLayout(gb);

    int i, j;
    fldObjects = new Vector(db.getFieldCount());
    for (i = 1; i <= db.getFieldCount(); i++) {
      j = i - 1;
      f = db.getField(i);
      if (f.isMemoField() || f.isPictureField()) {
        b = new Button(db.getField(i).getName());
        b.addActionListener(this);
        addComponent(
            viewPane, b, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(b);
      } else if (f.getType() == 'L') {
        c = new Checkbox(db.getField(i).getName(), true);
        addComponent(
            viewPane, c, 1, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(c);
      } else {
        l = new Label(db.getField(i).getName(), Label.RIGHT);
        addComponent(
            viewPane, l, 0, j, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        int ln = f.getLength();
        if (ln > 100) {
          ln = 100;
        }
        t = new TextField(db.getField(i).getName(), ln);
        if (width < ln * 10) {
          width = ln * 10;
        }
        addComponent(
            viewPane, t, 1, j, ln, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
        fldObjects.addElement(t);
        t.setEditable(true);
      }
      height += 10;
    }

    crl.setText("Record " + db.getCurrentRecordNumber());
    trl.setText(" of " + db.getRecordCount());
    SBrecpos.setMaximum(db.getRecordCount());
    addComponent(viewPane, crl, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(viewPane, trl, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(
        viewPane, SBrecpos, 0, i, 2, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, delCB, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(
        viewPane, Prev, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Next, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    i++;
    addComponent(viewPane, Add, 0, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Update, 1, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    addComponent(
        viewPane, Clear, 2, i, 1, 1, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST);
    Prev.setEnabled(false);
    prevRecord.setEnabled(false);
    if (db.getRecordCount() == 0) {
      Update.setEnabled(false);
      updateRecord.setEnabled(false);
      Next.setEnabled(false);
      nextRecord.setEnabled(false);
    }

    dimView.setSize(width + 150, height + 150);
    sp.setSize(dimView);

    goTo(1);
  }
Beispiel #2
0
 /**
  * The child component has been resized. The scrollbars must be updated with the new sizes. At the
  * native level the sizes of the actual windows may not have changed yet, so the size information
  * from the java-level is passed down and used.
  */
 public void childResized(int width, int height) {
   ScrollPane sp = (ScrollPane) target;
   Dimension vs = sp.getSize();
   setSpans(vs.width, vs.height, width, height);
   setInsets();
 }