Hello.

We have a little problem using a ULCRegularExpressionDataType for
validating the user input in tables. When trying to integrate the datatype
as cell editor for a table and starting the application with speakers
turned on, you hear the warning audio sound from Windows (XP). When
scrolling down the sound appears multiple for each table row. This
behaviour only seems to come up the first time a row is "loaded". Please
see the snipped below to rebuild the situation. We use ULC version 6.1.1
and the default sound configuration for Windows XP.

May be we are integrating the datatype the wrong way, so we will be glad,
if you have any hint or idea to solve this problem.


Best regards,
Daniel


+++ SNIPPED +++

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.IEditorComponent;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.application.datatype.ULCRegularExpressionDataType;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.application.table.ITableCellEditor;
import com.ulcjava.base.application.table.ULCTableColumn;
import com.ulcjava.base.application.table.ULCTableColumnModel;
import com.ulcjava.base.development.DevelopmentRunner;

public class TableValidationEditorSnipped extends AbstractApplication {

  public void start() {
    final SnippetTableModel tableModel = new SnippetTableModel();
    final ULCTable table = new ULCTable(tableModel);

    // only the last column has a checkbox cell renderer and cell editor
    ULCTableColumnModel columnModel = table.getColumnModel();
    ULCTableColumn column = columnModel.getColumn(1);

    // default typed cell editor
    column.setCellEditor(new ITableCellEditor() {
      public IEditorComponent getTableCellEditorComponent(ULCTable table,
        Object value, int row) {
        final ULCTextField tf = new ULCTextField();
        ULCRegularExpressionDataType validator = new
        ULCRegularExpressionDataType("[09]", "[09]*");
        tf.setDataType(validator);
        return tf;
      }
    });

    ULCButton clickBtn = new ULCButton("Click me!");
    clickBtn.addActionListener(new IActionListener() {
      public void actionPerformed(ActionEvent event) {
        // This is the callable table frame
        ULCFrame popup = new ULCFrame("Popup Window");
        popup.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);

        ULCBoxPane tableContent = new ULCBoxPane(1, 0);
        tableContent.add(ULCBoxPane.BOX_EXPAND_EXPAND, new
        ULCScrollPane(table));
        popup.add(tableContent);

        popup.setLocationRelativeTo(null);
        popup.setVisible(true);
        popup.toFront();
      }
    });

    ULCBoxPane content = new ULCBoxPane(1, 0);
    content.add(ULCBoxPane.BOX_CENTER_CENTER, clickBtn);

    // This is the calling frame
    ULCFrame frame = new ULCFrame("TableValidationEditorSnipped");
    frame.setDefaultCloseOperation(ULCFrame.DISPOSE_ON_CLOSE);
    frame.add(content);

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.toFront();
  }

  /**
   * Start method.
   *
   * @param args - optional
   */
  public static void main(String[] args) {
    DevelopmentRunner.setApplicationClass(TableValidationEditorSnipped.class);

    DevelopmentRunner.main(args);
  }

  // -- TableModel
  ------------------------------------------------------------

  /**
   * The TableModel.
   */
  private static class SnippetTableModel extends DefaultTableModel {
    public Object getValueAt(int row, int column) {
      return "0";
    }

    public void setValueAt(Object value, int row, int column) {
      super.setValueAt(value, row, column);
    }

    public int getRowCount() {
      return 250;
    }

    public int getColumnCount() {
      return 2;
    }

    public String getColumnName(int column) {
      return "C" + column;
    }
  }
}

Reply via email to