Programmatically activate a cell

I have a Spark editable datagrid. A user has an ability to add a new row. I want to activate a cell for editing in the new row without clicking on a cell. Is that possible?
Here is my code:
var engine:XMLList = newEngine.copy();
engines.dataProvider.addItemAt(engine, engines.dataProvider.length);
engines.setSelectedIndex(engines.dataProvider.length - 1);     
engines.validateNow();
engines.startItemEditorSession(engines.dataProvider.length - 1, 0);
I still have to click on a cell in the first column to start editing.
Thanks

The code I have provided in my original message is the only code I have:
var engine:XMLList = newEngine.copy();
engine.header_id = consistHeaderModel(model).id;
engines.dataProvider.addItemAt(engine, engines.dataProvider.length);
engines.setSelectedIndex(engines.dataProvider.length - 1);   
engines.validateNow();
engines.setFocus(); // Added this. No difference.
engines.startItemEditorSession(engines.dataProvider.length - 1, 0);
I am running this when a user clicks on column's header. I have a custom header renderer for that. here is some code:
override protected function createChildren() : void
            var addRow:Image = new Image();
            addRow.buttonMode = true;
            addRow.useHandCursor = true;
            addRow.toolTip = toolTipStr;
            addRow.addEventListener("click", clickHandler);
            addRow.source = imgClass;
            addElement(addRow);
            validateDisplayList();
        protected function clickHandler(event:Event):void
            var dynEvent:DynamicEvent = new DynamicEvent(eventToRise, true);
            dispatchEvent(dynEvent);           
More details.
I am using a custom itemEditor for the column:
<s:itemEditor>
     <fx:Component>
     <local:gridTextEditor restrict="^0-9"/>                                   
     </fx:Component>
</s:itemEditor>
where gridTextEditor is the following:
package
    import spark.components.DataGrid;
    import spark.components.TextInput;
    import spark.components.gridClasses.GridItemEditor;
    import spark.components.gridClasses.IGridItemEditor;
    public class gridTextEditor extends GridItemEditor implements IGridItemEditor
        private var valueDisplay:TextInput;
        public var restrict:String;
        public function gridTextEditor()
            //TODO: implement function
            super();
            valueDisplay = new TextInput();
            valueDisplay.setStyle("borderVisible", false);
            valueDisplay.setStyle("unfocusedTextSelectionColor", "#70b2ee");
            //valueDisplay.selectionHighlighting = "always";
            addElement(valueDisplay);
            valueDisplay.x += 4;
            valueDisplay.y += 3;
        override public function prepare():void
            super.prepare();
            valueDisplay.restrict = restrict;
            valueDisplay.width = column.width - 6;
            valueDisplay.selectRange(0, valueDisplay.text.length);
        override public function save():Boolean
            data[column.dataField] = value;
            DataGrid(owner).validateNow();
            return true;
        override public function get value():Object
            return valueDisplay.text;           
        override public function set value(newValue:Object):void
            valueDisplay.text = newValue.toString();

Similar Messages

  • Programmatically selecting a cell in a two-dimensional JTable

    The problem is that when a person edits a cell and the value fails validation, I would like to programmatically select the cell. The validation is done in the setValueAt method of a Class extending the AbstractTableModel. By simply returning out of that method, the cell value is set back to the way it was before the user changed it. In addition, I would like the problem cell to be automatically selected rather than requiring the user to click in it to select it. The first question is 1- Is this possible, and 2- Any clues as to how to select it?
    We find for examle in Chapter 6 of the CoreJava 2 Vol II Advanced features statements like this on page 399 of, I think, Edition 4, (can anyone tell what edition it is?) by Cay Horstmann
    void setCellSelectionEnabled(boolean b)
    If b is true, then individual cells are selected (when the user clicks in the cell?). I have researched this problem for several days and don't have a clue how to automatically select the cell although I know precisely what row and column it is.

    This is the code to return the focus to error cell.
    /* TableCellValidator class */
    /* The class basically validates the input entry in a cell and */
    /* pops up a JOptionPane if its an invalid input */
    /* And an OK is clicked on the JOptionPane, the control returns back */
    /* to the same cell */
    /* Basic Idea: The controls Arrow/Tab/mouse clicks are handled by our */
    /* ----------- custom table. Its has been slightly tricky to handle */
    /* mouse clicks, since when you click the next cell, the */
    /* editingrow/editingcol advances. Hence the */
    /* previousrow/previouscol has been captured in the */
    /* setValueAt method. */
    /* To capture Table/Arrow/Numeric Arrow, The keyStrokes(TAB etc)*/
    /* assigned different AbstractionActions to execute like */
    /* validateBeforeTabbingToNextCell */
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableCellValidator {
    * Constructor.
    * Basically instantiates the class and sets up the
    * JFrame object and the table.
    public TableCellValidator() {
    JFrame f = new JFrame("JTable test");
    f.getContentPane().add(new JScrollPane(createTable()), "Center");
    f.pack();
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    * A method which created our custom table.
    * The JTable methods processMouseEvent
    * and setValueAt are overridden to handle
    * Mouseclicks.
    * The Tables ActionMap is fed with different
    * AbstractAction classes eg: (validateBeforeTabbingToNextCell)
    * (Scroll down below for the innerclass
    * validateBeforeTabbingToNextCell).
    * So basically when TAB is pressed the stuff present
    * in the validateBeforeTabbingToNextCell's actionPerformed(..)
    * method is performed.
    * So we need to handle all the stuff a TAB does.
    * ie. if a TAB hits the end of the row, we need to increment
    * it to the next Row (if the validation is successful)
    * in the current row etc..
    * @return JTable
    * @see validateBeforeTabbingToNextCell
    * @see validateBeforeShiftTabbingToNextCell
    * @see validateBeforeMovingToNextCell
    * @see validateBeforeMovingDownToCell
    * @see validateBeforeMovingUpToCell
    * @see validateBeforeMovingLeftToCell
    private JTable createTable() {
    JTable table = new JTable(createModel()){
    private int previousRow =0;
    private int previousCol =0;
    * Processes mouse events occurring on this component by
    * dispatching them to any registered
    * <code>MouseListener</code> objects.
    * <p>
    * This method is not called unless mouse events are
    * enabled for this component. Mouse events are enabled
    * when one of the following occurs:
    * <p><ul>
    * <li>A <code>MouseListener</code> object is registered
    * via <code>addMouseListener</code>.
    * </ul>
    * <p>Note that if the event parameter is <code>null</code>
    * the behavior is unspecified and may result in an
    * exception.
    * @param e the mouse event
    * @see java.awt.event.MouseEvent
    * @see java.awt.event.MouseListener
    * @see #addMouseListener
    * @see #enableEvents
    * @since JDK1.1
    protected void processMouseEvent(MouseEvent e) {
    boolean canMoveFocus = true;
    int currentRowAndColumn[] = getCurrentRowAndColumn(this); //we pull the current row and column
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    if ( e.getID() == MouseEvent.MOUSE_PRESSED || e.getID() == MouseEvent.MOUSE_CLICKED) {
    stopCurrentCellBeingEdited(this); //stop the cellbeing edited to grab its value
    final String value = (String)getModel().getValueAt(row,column);
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    SwingUtilities.invokeLater(new Runnable(){
    public void run() {
    JOptionPane.showMessageDialog(null,"Alpha value ="+ value ,"Invalid entry!",JOptionPane.WARNING_MESSAGE);
    changeSelection(previousRow,previousCol, true, true);
    editCellAt(previousRow, previousCol);
    requestFocus(); // or t.getEditorCompo
    if ( canMoveFocus ) {
    super.processMouseEvent(e);
    * The method setValueAt of the JTable is overridden
    * to save the previousRow/previousCol to enable us to
    * get back to the error cell when a Mouse is clicked.
    * This is circumvent the problem, when a mouse is clicked in
    * a different cell, the control goes to that cell and
    * when you ask for getEditingRow , it returns the row that
    * the current mouse click occurred. But we need a way
    * to stop at the previous cell(ie. the cell that we were editing
    * before the mouse click occurred) when an invalid data has
    * been entered and return the focus to that cell
    * @param aValue
    * @param row
    * @param col
    public void setValueAt(Object aValue,int row, int col) {     
    this.previousRow = row;
    this.previousCol = col;
    super.setValueAt(aValue,row,col);
    /* These are the various KeyStrokes like
    ENTER,SHIFT-TAB,TAB,Arrow Keys,Numeric Arrow keys being assigned an Abstract action (key string ) in to the
    inputMap first . Then an Action is assigned in the ActionMap object
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0) ,"validateBeforeTabbingToNextCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,1) ,"validateBeforeShiftTabbingToNextCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0) ,"validateBeforeMovingToNextCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT,0) ,"validateBeforeMovingToNextCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0) ,"validateBeforeMovingDownToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN,0) ,"validateBeforeMovingDownToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0) ,"validateBeforeMovingDownToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP,0) ,"validateBeforeMovingUpToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP,0) ,"validateBeforeMovingUpToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,0) ,"validateBeforeMovingLeftToCell");
    table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT,0) ,"validateBeforeMovingLeftToCell");
    table.getActionMap().put("validateBeforeTabbingToNextCell",
    new validateBeforeTabbingToNextCell());
    table.getActionMap().put("validateBeforeShiftTabbingToNextCell",
    new validateBeforeShiftTabbingToNextCell());
    table.getActionMap().put("validateBeforeMovingToNextCell",
    new validateBeforeMovingToNextCell());
    table.getActionMap().put("validateBeforeMovingDownToCell",
    new validateBeforeMovingDownToCell());
    table.getActionMap().put("validateBeforeMovingUpToCell",
    new validateBeforeMovingUpToCell());
    table.getActionMap().put("validateBeforeMovingLeftToCell",
    new validateBeforeMovingLeftToCell());
    table.setPreferredScrollableViewportSize(table.getPreferredSize());
    return table;
    * A table model is created here for 5 rows/5 columns.
    * And the isCellEditable is overridden to return true,
    * indicating that the cell can be edited.
    * So fine tuned control can be done here by saying,
    * the user can be allowed to edit Row 1,3 or 5 only.
    * or column 1 only etc..
    * @return DefaultTableModel
    private DefaultTableModel createModel() {
    DefaultTableModel model = new DefaultTableModel(5, 5) {
    public boolean isCellEditable(int row, int column) {
    return true;
    return model;
    * This method basically returns the currentRow/currentCol value
    * If the current Row/Col is being edited then
    * it returns the getEditingRow/getEditingColumn
    * If its not being edited,
    * it return the getAnchorSelectionIndex of the JTables
    * ListSelectionModel.
    * If the column or row is -1, then it return 0.
    * The first element in the int[] array is the row
    * The second element in the int[] array is the column
    * @param t input a JTable
    * @return int[]
    * @see ListSelectionModel
    * @see JTable
    private int[] getCurrentRowAndColumn(JTable t){
    int[] currentRowAndColum = new int[2];
    int row, column;
    if (t.isEditing()) {
    row = t.getEditingRow();
    column = t.getEditingColumn();
    } else {
    row = t.getSelectionModel().getAnchorSelectionIndex();
    if (row == -1) {
    if (t.getRowCount() == 0) {
    //actually this should never happen.. we need to return an exception
    return null;
    column =t.getColumnModel().getSelectionModel().getAnchorSelectionIndex();
    if (column == -1) {
    if (t.getColumnCount() == 0) {
    //actually this should never happen.. we need to return an exception
    return null;
    column = 0;
    currentRowAndColum[0]=row;
    currentRowAndColum[1]=column;
    return currentRowAndColum;
    * Tbis basically a wrapper method for CellEditors,
    * stopCellEditing method.
    * We need to do this because,
    * for instance we have entered a value in Cell[0,0] as 3
    * and when we press TAB or mouse click or any other relevant
    * navigation keys,
    * ** IF the cell is BEING EDITED,
    * when we do a getValueAt(cellrow,cellcol) at the TableModel
    * level , it would return "null". To overcome this problem,
    * we tell the cellEditor to stop what its doing. and then
    * when you do a getValueAt[cellrow,cellcol] it would
    * return us the current cells value
    * @param t Input a JTable
    * @see CellEditor
    private void stopCurrentCellBeingEdited(JTable t){
    CellEditor ce = t.getCellEditor(); /*this not the ideal way to do..
    since there is no way the CellEditor could be null.
    But a nullpointer arises when trying to work with mouse.. rather than just
    keyboard" */
    if (ce!=null) {
    ce.stopCellEditing();
    * The following Action class handles when a
    * RIGHT ARROW or NUMERIC RIGHT ARROW is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move it to the
    * next Cell.. else take it back to the currentCell
    class validateBeforeMovingToNextCell extends AbstractAction {
    * The following Action class handles when a
    * DOWN ARROW or NUMERIC DOWN ARROW is pressed.
    * There is just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move it to
    * down by one Cell.. else take it back to the currentCell
    * @param e
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    column++;
    if (column >= t.getColumnCount())
    column = column-1;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    * The following Action class handles when a
    * DOWN ARROW or NUMERIC DOWN ARROW is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move it to the
    * down by Cell.. else take it back to the currentCell
    class validateBeforeMovingDownToCell extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    row++;
    if (row >= t.getRowCount())
    row = row - 1;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    * The following Action class handles when a
    * UP ARROW or NUMERIC UP ARROW is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move the cursor/
    * editable status up by a Cell.. else take it back to the currentCell
    class validateBeforeMovingUpToCell extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    row--;
    if (row <0)
    row = 0;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    * The following Action class handles when a
    * LEFT ARROW or NUMERIC LEFT ARROW is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move the cursor/
    * editable status up by a Cell.. else take it back to the currentCell
    class validateBeforeMovingLeftToCell extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    column--;
    if (column <0)
    column = 0;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    * The following Action class handles when a TAB is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move the cursor/
    * editable status up by a Cell.. else take it back to the currentCell
    class validateBeforeTabbingToNextCell extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    column++;
    int rows = t.getRowCount(), columns = t.getColumnCount();
    while (row < rows) {
    while (column < columns) {
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    column++;
    row++;
    column = 0;
    row = 0;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    * The following Action class handles when a SHIFT TAB is pressed.
    * There just a basic checking for Numeric values
    * (Integer.parseInt) inside the code.
    * When validation is successfull, we need to move the cursor/
    * editable status up by a Cell.. else take it back to the currentCell
    class validateBeforeShiftTabbingToNextCell extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
    JTable t = (JTable) e.getSource();
    int currentRowAndColumn[] = getCurrentRowAndColumn(t);
    int row = currentRowAndColumn[0];
    int column = currentRowAndColumn[1];
    stopCurrentCellBeingEdited(t);
    String value = (String)t.getModel().getValueAt(row,column);
    if (value!= null && !value.equals("")) {
    try {
    Integer.parseInt(value);
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null,"Please input numeric values at cell[row="+row+","+"col="+column+"]","Invalid Input!!",JOptionPane.WARNING_MESSAGE);
    t.changeSelection(row, column, true, true);
    t.editCellAt(row,column);
    t.getEditorComponent().requestFocus();
    return;
    column--;
    int rows = t.getRowCount(), columns = t.getColumnCount();
    while ((row < rows) && (row >= 0)) {
    while ((column < columns) && (column >= 0)) {
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    column--;
    row--;
    column = columns - 1;
    row = rows - 1;
    if (t.isCellEditable(row, column)) {
    t.changeSelection(row, column, true, true);
    t.editCellAt(row, column);
    if ((t.getEditingRow() == row)
    && (t.getEditingColumn() == column)) {
    t.requestFocus();
    return;
    public static void main(String[] args) {
    new TableCellValidator();

  • JTable - Programmatically selection multiple cells

    Hi!
    I'd like to know wether it's possible to programmatically select certain cells of a Jtable component.
    For example:
    My Jtable looks like that
    1 2 3
    4 5 6
    7 8 9
    and I want to select cell 2,4 and 7. How could I do that??
    Thanks for answers...

    Hello,
    I consciously read your thread, but I still can't get the sample code running.
    (java.lang.StackOverflowError
    Exception in thread "main" )
    Would you please give me a hint?
    Or better,
    send or post me the sample code of your class 'AttributiveCellTableModel', please.
    Thank you very much in advance!
    Thorsten

  • How to programmatically change the cell color of an ADF table ?

    Hi all,
    I have an ADF table with some fields on it. Depending on the value of a field named, say, "F1", I would like to change its background color.
    So far I can change the field color with this EL expression inside the InlineStyle table column property:
    font-size:medium; background-color:#{viewScope.myBean.setColor};
    where setColor is a bean function, in where I access the field "F1" via binding, parse its value, and return the right value - so far, so good.
    The bad thing is, the InlineStyle affects that field in all the rows of the table, while I would like to change only the field in the rows, which have that specific value in it.
    So for example having the rows:
    F1
    abc#1 ----> currently selected row
    cde#2
    efg#3
    I want to change the background color to all the F1 fields which have a "1" after the '#' and let the other "F1" row cells background color stay unchanged.
    But as you can imagine, the InlineStyle affect the "F1" background color in all the rows (assuming that the first row of the table is selected).
    So the question: how to access a single cell of a row in an ADF table, and programmatically change its background color ?
    So far I can iterate through the ADF table with:
    BindingContext bindingctx = BindingContext.getCurrent();
    BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
    DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("aTableIterator");//access the iterator by its ID value in the PageDef file
    RowSetIterator rsi = dciter.getRowSetIterator();
    System.out.println("rsi getrowcount = " rsi.getRowCount());+
    Row row = null;
    +if (rsi.getRowCount() > 0) {+
    row = rsi.getCurrentRow();
    System.out.println("row attr = " Arrays.toString(row.getAttributeNames()));+
    System.out.println("class : " row.getAttribute("F1").getClass().toString());+
    +}+
    +while (rsi.hasNext()) {+
    row = rsi.next();
    System.out.println("row attr = " Arrays.toString(row.getAttributeNames()));+
    +}+
    Regards,
    Sergio.

    Hi,
    I mean a specific cell within a row.
    Here are two pictures that show an ADF table with two rows and some fields on it:
    https://skydrive.live.com/?cid=7D3084D8BF755808&id=7D3084D8BF755808!107&sc=documents#cid=7D3084D8BF755808&id=7D3084D8BF755808!107&sc=documents
    bild_A is what I have, bild_B is what I would like. Note that:
    in bild_A the first row contain a yellow background color for the field F4 and an orange background color for the field F5. This is correct, because F4 has an "1" at the end of its string value, and F5 has a "3" at the end. So far so good.
    But the second row (again, bild_A) has also the fields F4 with yellow background color, and the field F5 with orange background color, even if the value in both fields is 0.
    What is should be, is shown in bild_B.
    The problem is that the solution provided affects all the cells of the column, while I need to change the background color of a single cell, and leave the other unchanged (see bild_B).
    I hope that clarify a bit :)
    Sergio.

  • Programmatically change selected cell/row of multicolumn listbox

    I want to programmatically change the selected cell of a multicolumn list box whose Selection Mode is set to Highlight Entire Row.  I would use this to be able to highlight which ever row of the listbox I choose to.  It would function in the same manner as if the user had clicked on a row to select it and highlight that particular row.  Setting the Active Cell does not accomplish this.
    Steve
    Solved!
    Go to Solution.

    Assigning the Value property works to change the selected and highlighted row.  Thanks

  • Programmatically select a cell on pivotTable

    Hi,
    I have a case where on initial load of a page that contains a pivot table with dates as columns, on the first row, the current day cell should be selected .
    Pivottable has a selection property accepting oracle.adf.view.faces.bi.component.pivotTable.Selection but I can’t find how to instantiate and set a proper Selection object.
    There are many examples for how to handle similar scenario using table component but nothing for pivot and the documentation is very limited.
    Any help for achieving the desired functionality would be very appreciated.
    Yiannis

    Any help ?

  • Programmatically pick a cell from a table

    Hello
    Programming in XCode.
    I have a table in view.
    I have a shake detection implemented.
    Now I want that, as you shake the device, a random cell is picked from the table as the new one that is selected.
    I have a random number for the row generization which doesn't exceed the list count.
    Now I want to execute something to pick, to highlight the randomly generated row of choice.
    I hav no idea what command or call to use.
    Please help!
    Kind Regards,
    Jan

    This does the job of setting an indexpath right. (randomrij is randomrow, eentabelview is atableview)
    NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:randomRijinSection:0];
    [[self eenTabelView] scrollToRowAtIndexPath:scrollIndexPathatScrollPosition:UITableViewScrollPositionNone animated:NO];
    Still nothing changes in the view, the row isn't made active.
    Should there be extra code to make it happen or is there something wrong with these two lines of code given here.
    For example, do there exist multiple NSindexPaths and did I set some virtual IndexPath to the random row.

  • Programmatically Editing a Cell Not Working

    Hi Guys,
    I'm trying to automatically begin editing a cell within a JTable as soon as the table is displayed.
    I've tried using the table.editCellAt(int row, int col) method but it just seems to have no effect.
    I've set the cell editable within my custom table class (and I know it is because if I double click on the cell or type anything then the editor is displayed).
    FYI I'm using Java 1.5
    Anyone got any ideas?

    Does nobody know how to automatically engage the editor component of a JTable programatically i.e. without having to click on the cell?? The code I gave you above works fine for me in JDK1.4.2. Why don't you post the 10 line demo program you are using to test my suggestion. That way people can determine whether you test code is wrong or 1.5 isn't working.

  • HT204380 How i activate face time usig my data plan, i have an iphon 4 but does not allow me to activate use cell data.

    Can some body help me?

    The iPhone 4 does NOT support FaceTime over cellular data connection.  Only models 4S and 5 currently support this.

  • Unable to programmatically edit a new cell

    Hi,
    I need to programmatically insert a new row in the table and then programmatically edit certain cell(s) in that row. The edit just after the insert is not working. Could you please advise?
    Thx
    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ButtonBuilder;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableColumnBuilder;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TableViewBuilder;
    import javafx.scene.control.TextField;
    import javafx.scene.control.TextFieldBuilder;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.VBox;
    import javafx.scene.layout.VBoxBuilder;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    public class ProgramaticEditTableViewApplication extends Application {
        public ProgramaticEditTableViewApplication() {
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(Stage stage) throws Exception {
             ObservableList<Person> data = FXCollections.observableArrayList(new Person("John"));
            final TableColumn<Person, String> firstNameCol = TableColumnBuilder.<Person, String>create().text("First Name").cellValueFactory(new PropertyValueFactory<Person, String>("firstName")).minWidth(100).build();
            firstNameCol.setCellFactory(new Callback<TableColumn<Person, String>, TableCell<Person, String>>() {
                    @Override
                    public TableCell<Person, String> call(TableColumn<Person, String> tablecolumn) {
                        return new EditingCell();
            final TableView<Person> table = TableViewBuilder.<Person>create().editable(true).items(data).build();
            table.getColumns().addAll(firstNameCol);
            Button addAndEditBtn = ButtonBuilder.create().text("Add&Edit").onAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent actionEvent) {
                            Person newPerson = new Person("new");
                            table.getItems().add(newPerson);
                            table.edit(0, firstNameCol);
                    }).build();
            VBox root = VBoxBuilder.create().children(table, addAndEditBtn).build();
            Scene scene = new Scene(root, 400, 400);
            stage.setScene(scene);
            stage.show();
        class Person {
            private final SimpleStringProperty firstName;
            private Person(String fName) {
                this.firstName = new SimpleStringProperty(fName);
            public String getFirstName() {
                return firstName.get();
            public void setFirstName(String fName) {
                firstName.set(fName);
        class EditingCell extends TableCell<Person, String> {
            private TextField textField;
            public EditingCell() {
            @Override
            public void startEdit() {
                super.startEdit();
                createTextField();
                setText(null);
                setGraphic(textField);
                textField.selectAll();
            @Override
            public void cancelEdit() {
                super.cancelEdit();
                setText((String) getItem());
                setGraphic(null);
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                if (empty) {
                    setText(null);
                    setGraphic(null);
                } else {
                    if (isEditing()) {
                        if (textField != null) {
                            textField.setText(getString());
                        setText(null);
                        setGraphic(textField);
                    } else {
                        setText(getString());
                        setGraphic(null);
            private TextField createTextField() {
                if (textField == null) {
                    textField = TextFieldBuilder.create().text(getString()).minWidth(this.getWidth() - (this.getGraphicTextGap() * 2)).build();
                    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
                            @Override
                            public void changed(ObservableValue<? extends Boolean> observableValue, Boolean arg1, Boolean arg2) {
                                if (!arg2) {
                                    commitEdit(textField.getText());
                return textField;
            private String getString() {
                return (getItem() == null) ? "" : getItem().toString();
    } Thx,
    Edited by: 891575 on Aug 31, 2012 9:11 AM
    Edited by: 891575 on Sep 3, 2012 4:11 AM

    Hi,
    I tried nothing change
    Let me re-explain my issue:
    I have a table control and an "Add&Edit" button. When the user clicks on the "Add&Edit" button I need to add a new empty row to the table then changing the state of the new added cell to editable(showing a textarea and giving the user the ability to directly type text)
    The add is working fine but the table.edit(...) call just after the add is not working.
    Note that if the table.edit(...) isn't called just after the add it is working fine
    Any idea why the edit is not working if I call it just after the add:
    data.add(newPerson);
    table.edit(0, firstNameCol);Thx
    Edited by: 891575 on Sep 3, 2012 4:12 AM

  • Wrong cell #

    I have been without my cell for over a month now.  My son was helping to activate my new phone and it has the wrong cell #.  It is showing (removed) and it should be (removed).  I NEED to activate my cell, so how does it get changed to the correct #? 
    Private info removed as required by the Terms of Service.
    Message was edited by: Admin Moderator

    Hello txflwr48! I regret the difficulties you've been having while activating your new phone. I'd love to help, but I recommend that we take our conversation to direct message instead of here in the public forum. If you have not yet gotten your device activated, please follow these steps to follow my handle (DionM_VZW) send me a direct message: http://vz.to/1gBiqkv
    DionM_VZW
    Follow us on Twitter www.twitter.com/vzwsupport

  • Keep Previous Value of Cell

    Hi there,
    I have two columns, let's call them Event Date (Column A) and Previous Event Date (Column B).
    I would like to implement some <acronym title="visual basic for applications">VBA</acronym> code (or use formulas if necessary) that automatically keeps the previous value of Event Date and retains it in the adjacent cell for Previous
    Event Date.
    For example, if A3 = Jan-03 and I update A3 to Jan-04, B3 would then show Jan-03 as it is the previous value of the cell.
    I would like this code to work for a whole column of cells, not just a single cell.
    I'm open to any & all ideas and appreciate the help. If any clarifications are necessary, just let me know.

    Right-click the sheet tab.
    Select View Code from the context menu.
    Copy the following code into the worksheet module:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim newVal As Variant
    ' Code won't work if multiple cells have been changed
    If Target.Count > 1 Then
    Exit Sub
    End If
    ' Only act if cell in column A has been changed
    If Intersect(Range("A:A"), Target) Is Nothing Then
    Exit Sub
    End If
    ' Turn off events and screen updating
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    ' Get new value
    newVal = Target.Value
    ' Undo to restore old value
    Application.Undo
    ' Copy old value to adjacent cell
    Target.Offset(0, 1).Value = Target.Value
    ' Redo the change
    Target.Value = newVal
    ' Turn on screen updating and events
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End Sub
    Remarks:
    If you change multiple cells at once, the code won't do anything.
    When you change a cell in column A, that cell will remain the active cell, i.e. Tab or Enter won't activate another cell.
    When you change a cell in column A, Undo will be disabled.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Cell Broadcast / Cell Info Display is not static i...

    Good Afternoon,
    I come by this means can try to explain how a situation that saw the Nokias 6210 Navigator.
    A customer information to activate the cell and the cell to receive the information by the same operator appears next to the hours over the name of the profile but is not static, or appears and disappears immediately.
    In other Nokias I have checked the information of the cell is always static display of the phone does not disappear. I wonder how can get this information to Nokia to the next versions of firmware updates to correct this situation, there are customers who use certain services of the operators such as the case of TMN TMN that has regional and customer needs to see what indicative of the area where you are and thus becomes complicated because you do not see the same information by not being static.
    Can perform this experiment with a Nokia 6210 Navigator and a Nokia E65 or 6630 and others in which information is fixed.
    It was with considerable difficulties in Spain which could capture information of the cell with Nokia 6210 Navigator, and therefore opted to take pictures with a nokia 6630 and N-Gage.
    No other matter of time, support me with high esteem and consideration
    Carefully
    Examples:
    Nokia 6630
    Nokia 6210 Navigator
    Message Edited by rsaraiva on 23-May-2009 03:51 PM

    If it helps, it may be whether operators actually support it, as my nokia x6 from vodafone use to display it but as soon as I unlocked it and siwtched to T Mobile it's stopped. I have now just switched it onto gsm connection only and it doesn't work so it could well be operator support dependent

  • Read all cells from an Excel file?

    Hi!
    I'm trying to read every cell from an Excel spreadsheet file, e.g.
    test.xls. The example in the NI Dev Zone (ActiveX Read Cells from
    Excel2000 VI) works if you know in advance what the first and last cell
    are, e.g. A1 and E453.
    The trouble is that the number of rows & columns in the file will vary;
    the last cell of 1 file might be E453, another might end at F29.
    How can I programmatically read every cell in the file? I thought of 2
    approaches:
    1: Find an ActiveX property that returns the last cell (or last row and
    last column).
    2: Use some other way to read an .xls file, maybe not by launching Excel
    but by using another program ...
    The NI applications engineer couldn't find a reasonably easy solution,
    so I'd w
    elcome any input.
    Thanks! Mark

    Mark,
    I haven't been able to find out if there is an ActiveX property or method the excel exposes to be able to do this ... searching on http://msdn.microsoft.com didn't return anything particularly useful.
    I've tried this sort of thing a couple of different ways. The simplest is if I have control over the file generation code, in that case I've just used the first row A1 and B1 to contain the number or rows and columns respectively and moved on from there.
    If that isn't a possibility then you could enter nonsense data around the acutal data and then look for that and then resize the array. This could get pretty slow if you read row by row, I've somtimes read chuncks of rows and then adjusted the next read and and combined arrays. With a large data set the memory and s
    peed implications do need to be looked at.
    The last thing is what you are referring to in 2. You should be able to save the .xls file as a comma delimited file. In this case the "Read for Spreadsheet File" vi should be able to just read all the data in. I'm not sure how easy it is to export an .xls file to a comma delimited format programatically.
    I think this should work all though I haven't tried it. If it doesn't then you could just read one row and then count the number of commas to determine the number of columns. You can then read the entire file and convert the data into an array, as every comma would separate each column and a carriage return would seperate each row.
    Haven't got LabVIEW on this machine so if I find anything new tomorrow I'll post again.
    Kamran

  • How do I change ALL cells in a Multi-Cloumn List box at one time ?

    I would like to change ALL of the Cells in a Multi-Column Listbox at one time. Both, with the Editor and Programmatically. Any Ideas ?

    Programmatically:
    Use "Active cell" property node, create constant and type "-2" in both elements of the cluster constant.
    Note: the first element is for the raw, the second for the column. -1 and -2 have special meanings.
    -1: header of column (listbox has no header for the raws)
    -2: all cells (of raw or column)
    So for example:
    -2;0: all cells of column 0 (with header)
    -2; -2: all cells (with header)
    -1;0: header of column 0
    -1;-2: header of all columns

Maybe you are looking for

  • DIFFERENT type of mms problem (receivers can't view)

    Hey all, I have a different mms problem after updating my 3GS to ios 4... Seems I can send mms and videos just fine, however the end receiver just sees a still image and hears the audio. I've done a lot of tests with this, and my wife's 3GS does the

  • Making Your Own Map Component in crystal xcelsius 2008

    Post Author: sam pewgo CA Forum: Xcelsius and Live Office It was disappointing that one could not make or import users own maps into CX 4.5has this issue been resolved in CX 2008?? Thanks in advanceSam

  • Question about migration from 10.1.0.5 to 10.2

    Hi, I've 10g 10.1.0.5 installed (by installing some patches). Now I need 10.2. Can I reach this with pathches (and which one(s)), or do I have to install from scratch an 10.2 ? Any reaction will be appreciated. Leo

  • HT204370 can i download a movie onto usb drive to watch on tv

    I am computer illiterate. Can i download a movie onto a usb drive to watch on tv?

  • CS3 for all icon sets

    how do i install them? the icon open up in text edit? thats not right! i thought they were pngs or something... I'm new to custimizing the mac's icons...but maybe somebody can help me since the CS3 for all creators website is in what looks like Spani