Table cells editing

I have a table with few rows and columns filled up with certain values. I edit a cell. Now if i get the DataVector of the table this edited value is not obtained. If I try clicking some other cell after editing then get the DataVector the edited value is obtained. Why is this??? Should I have any Listeners added?? Please reply in depth

Hi,
hmm ... it seems, that the editing progress was not finished in the first case. JTable updates an entry in the datamodel only if the editing process is finished. As long as you see the blinking cursor in this field, editing is in progress and you can avoid storing by pressing ESC - but when you TAB to another cell or click another cell, the editing process is finished and the data is updated in the datamodel.
greetings Marsian

Similar Messages

  • Table cell editing

    how to edit table cells ? i am trying it since 2 days. with different errors. it's throwing some null pointer exception.
      public TableView getTableview() {
             TableView<Contact> fx2TableView = new TableView<Contact>();
             public  TableColumn<String> firstNameCol = new TableColumn<String>("First Name");
            fx2TableView.setLayoutX(260);
            fx2TableView.setLayoutY(20);
            fx2TableView.setOnMouseClicked(new EventHandler<MouseEvent>() {
                public void handle(MouseEvent event) {
                       if(event.getClickCount()==2) {
                       System.out.println(fx2TableView.getEditingCell().getRow());
            AccountDb myTableData = new AccountDb();
            ObservableList<Contact> teamMembers = FXCollections.observableArrayList(myTableData.mymain());
            fx2TableView.getItems().clear();
            fx2TableView.setItems(teamMembers);
            firstNameCol.setDataRetriever(new Callback<CellDataFeatures<String>, String>() {
                public String call(CellDataFeatures<String> c) {
                    return ((Contact) c.getValue()).getFirstName();
            TableColumn middleNameCol = new TableColumn("Middle Name");
            middleNameCol.setDataRetriever(new Callback<CellDataFeatures<String>, String>() {
                public String call(CellDataFeatures<String> c) {
                    return ((Contact) c.getValue()).getMiddleName();
            TableColumn<String> lastNameCol = new TableColumn<String>("Last Name");
            lastNameCol.setDataRetriever(new Callback<CellDataFeatures<String>, String>() {
                public String call(CellDataFeatures<String> p) {
                    return ((Contact) p.getValue()).getLastName();
            fx2TableView.getColumns().addAll(firstNameCol, middleNameCol, lastNameCol);
            return fx2TableView;
        }now i can see the data from table . how to edit it . i tried few statements to print a particular cell data.
    by using
      System.out.println(fx2TableView.getEditingCell().getRow()); or
                      fx2TableView.edit(fx2TableView.getColumns(fx2TableView.getEditingCell()));
                   System.out.println(fx2TableView.getRowFactory().call(CellDataFeatures<String> c) {
                    ((Contact)c.getValue()).getFirstName()));
                 fx2TableView.getOnEditStart(new EventHandler<EditEvent>()) {
                  public void handle(EditEvent e) {
                    }); what to write ? i am totally lost . any example how to edit , save and cancel on tableview edit ?
    Thanks.
    Edited by: 809387 on Jun 9, 2011 9:49 AM

    Hello User you can easily modify your Table Cell . In context of your code I've made one sample editing cell for your 'first column'.
    firstNameCol.setCellFactory(new Callback<TableColumn<String>,TableCell<String>>(){
                public TableCell<String> call(TableColumn<String> param) {
                    final StackPane stack = new StackPane();               
                    final Label label = new Label("test");
                    final TextBox box = new TextBox("test");              
                    box.setVisible(false);
                    //adding children to stack z-index
                    stack.getChildren().add(label);
                    stack.getChildren().add(box);
                    final TableCell cell = new TableCell();
                    cell.setNode(stack);
                    //event listener for textbox
                    box.setOnKeyPressed(new EventHandler<KeyEvent>(){
                        public void handle(KeyEvent event) {
                            if(event.getCode()==(KeyCode.ENTER)){                           
                                box.setVisible(false);
                                label.setText(box.getText());                           
                                box.setFocusTraversable(false);
                    //property Change Listener of Focus in textbox               
                    box.focusedProperty().addListener(new ChangeListener<Boolean>(){
                        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                            if(!newValue){           
                                box.setVisible(false);
                                label.setText(box.getRawText());
                    //finally trigerring the visibility of textbox on double click
                    cell.setOnMouseClicked(new EventHandler<MouseEvent>(){
                        public void handle(MouseEvent event) {                      
                            if(event.getClickCount()==2)
                                box.setVisible(true);                       
                                box.requestFocus();
                    return cell;
            });The above code runs the editing textbox when tablecell is double clicked.
    You can manage the item of TableCell and make tablecell setNode() for more modification.
    Please read the API for more information.
    Thanks.
    Narayan

  • Making a Table cell editable. Please Help

    Hello there,
    I have written an Inner class called CallHeaderRenderer
    which is used to select to highlight a row from a table.
    But i am unable to edit the column data I click on.
    Please can any one tell me how to edit the column value when you double click on it??
    Attached is my Inner class used to select the concerned row.
    I am unable to edit the concerned column.....
    Please help.!!!
    What is the statement to make the cell editable!!!
    class CallHeaderRenderer extends DefaultTableCellRenderer{
    public CallHeaderRenderer(){
    super();
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
    // Set the highlight for record chosen.
    super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
    return this;
    }

    A renderer has nothing to do with editing the cell. I suggest you read this section from the Swing tutorial on "Using Tables" for an explanation of how tables work. The tutorial will give one method for making a cell editable:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    Here is an alternate way to make a cell editable:
    table = new JTable( ... )
        public boolean isCellEditable(int row, int column)
            //  All columns, except the first, are editable
            if (column == 0)
                return false;
            else
                return true;
    };

  • Table cells editing question...

    I have a JTable and I can set the type of input (ComboBox, CheckBox, TextField) for a hole column. How can I set the type of input differently for each cell in a column (like the properties tab window in the design module in JBuilder, for example)?

    You can implement TableCellEditor to return a different Component for a particular row, column, or value.

  • How to enable a table cell dynamically?

    Hi
    I have a javafx TableView with editable and non-editable columns. I have set editable columns CellFactory to a custom EditableTextCell.This makes the whole column editable on load of the Scene.
    I have one more requirement for the same table. I have to make the table cell editable at runtime based on a flag in item mapped to tablerow. Only a single row cell should get editable not all the cells in column. How to do that? Please suggest.

    Perhaps something like this
    create or replace view v_myview
    as
    select id, name, 'table1' as tbl_nm from table1
    union all
    select id, name, 'table2' from table2
    union all
    select id, name, 'table3' from table3
    union all
    select id, name, 'table4' from table4
    select name
      from v_myview
    where id = 101
       and tbl_nm = :P101_TABLE_NAME;

  • Blinking Cursor in Table Cell

    Can anybody tell me how I can blink the Cursor in the JTable. I am using JTable Cell as the user input field, I want to show a blinking cursor if user selects that cell.
    Thanks in adv

    Are your table cells editable? Are you talking about the Cursor in the TextField when your cell is edited? It is probably best to be as explicit as possible here.
    Josh Castagno
    http://www.jdc-software.com

  • How to listener a table cell

    I have this table cell editable and I want to listen when value changes (to update the database data) but I am not being able to do that, any help?
    I also would like to activate the new cell value with ENTER key, the way it is now I have to get ou of the cell clicking outside somewhere or using TAB key to move.
    I am using these tow classes to Editor and Renderer (for numbers):
    import java.awt.*;
    import java.text.*;
    import javax.swing.table.*;
    import javax.swing.*;
    public class DecimalRenderer extends DefaultTableCellRenderer {
        DecimalFormat  formatter;
        public DecimalRenderer(String pattern) {
            this(new DecimalFormat(pattern));
        public DecimalRenderer(DecimalFormat formatter) {
            this.formatter = formatter;
            setHorizontalAlignment(JLabel.RIGHT);
        public void setValue(Object value) {
            setText((value == null) ? "" : formatter.format(((Double)value).doubleValue()));
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            cell.setBackground( Color.white );
            cell.setForeground( Color.black );
            return cell;
    import java.awt.*;
    import javax.swing.table.*;
    import javax.swing.*;
    public class NumberCellEditor extends AbstractCellEditor implements TableCellEditor {
        //protected JTextField textField;
        protected JFormattedTextField textField;
        private JTable tableUsed;
        protected Object oldValue;
        public NumberCellEditor() {
            textField = new JFormattedTextField();
            textField.setEditable(true);
            textField.setHorizontalAlignment(SwingConstants.RIGHT);
            textField.setFont(new java.awt.Font("Tahoma", 1, 12));
            textField.setBackground(Color.white);
            textField.setForeground(Color.red);
        public NumberCellEditor(int decimal) {
            textField = new JFormattedTextField();
            textField.setEditable(true);
            textField.setHorizontalAlignment(SwingConstants.RIGHT);
            textField.setBackground(Color.white);
            textField.setForeground(Color.red);
            textField.setFormatterFactory(Lib.setFormatDouble(decimal));
            public NumberCellEditor(boolean currency, int decimal) {
            textField = new JFormattedTextField();
            textField.setEditable(true);
            textField.setHorizontalAlignment(SwingConstants.RIGHT);
            textField.setBackground(Color.white);
            textField.setForeground(Color.red);
            textField.setFormatterFactory(Lib.setCurrencyFormat(decimal));
        private void setConfig(){
            textField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    if(tableUsed.isEditing()){
                        tableUsed.getCellEditor().stopCellEditing();
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            //textField.setText(value.toString());
            textField.setValue(value);
            oldValue = value;
            this.tableUsed = table;
            String className = value.getClass().getName();
            System.out.println("Type: "+className);
            return textField;
        /** Returns the value contained in the editor */
        public Object getCellEditorValue() {
            String name = oldValue.getClass().getName();
            Object returnValue=null;
            try {
                if (name.equals("java.lang.Integer"))
                    returnValue = new java.lang.Integer(textField.getText());
                else if (name.equals("java.lang.Double"))
                    returnValue = (Double)textField.getValue(); //new java.lang.Double(textField.getText());
                else if (name.equals("java.lang.Float"))
                    returnValue = new java.lang.Float(textField.getText());
                else if (name.equals("java.lang.Long"))
                    returnValue = new java.lang.Long(textField.getText());
                else if (name.equals("java.lang.Short"))
                    returnValue = new java.lang.Short(textField.getText());
                else if (name.equals("java.lang.Byte"))
                    returnValue = new java.lang.Byte(textField.getText());
                else if (name.equals("java.math.BigDecimal"))
                    returnValue = new java.math.BigDecimal(textField.getText());
                else if (name.equals("java.math.BigInteger"))
                    returnValue = new java.math.BigInteger(textField.getText());
            } catch (NumberFormatException e) {}
            return returnValue;
    }My code to that column/cell:
    TableColumn columnValueService = tabelaListaQuantidade.getColumn(colunas[4]);
    columnValueService.setPreferredWidth(150);
    columnValueService.setCellRenderer(new DecimalRenderer("###,###,##0.00"));
    columnValueService.setCellEditor(new NumberCellEditor(true, 2));I would appreciate any help.
    Thanks

    I want to listen when value changes Use a TableModelListener
    I also would like to activate the new cell value with ENTER keyThis is the default behaviour with the default editors. I suggest you extend the default editor instead of extending the abstract editor

  • How to stop editing in a table cell

    i m using JTextArea as renderer and editor for table cell. While editing i want to stop editing in that cell at some perticular instance. i have used stopCellEditing() function on TableCellEditor but still the Caret does not goes away and when i press any key it still types that character at that place. I want to hide the Caret and do not want any character to print in the cell after calling stopCellEditing().

    What you have already done, and the resulting behavior is unclear from your post. Post more details.

  • Theme Editor: where to change backgroundcolor of editable table cells?

    Hi all,
    I need to change the color of an editable table cell.
    I navigated to the theme editor --> tables.There is a section "Editable Tables". The preview shows an example with three columns and tree rows. I want to change the backgroundcolor of the cell in the first row, third column (in SAP standard it is lightgrey).
    The backgroundcolor of the rows beneath can be changed in section "Selected Cells", the backgroundcolor of the first two columns in the first row can be changed by "Background Color of Standard Table Cell" but I can't find the field where I can change the color of the last cell.
    Best regards,
    Sandra

    Hi,
    The blue color come from your definitions on "Labels and Fields" to read-only color of input field.
    Regards,
    F.F

  • Table cells not editable in Contribute

    I have a date table (inside a CSS layout) which displays incorrectly in Contribute Edit mode.This is the URL http://www.greencs.co.uk/accreditations.html
    In Contribute Edit mode, the right hand column of the table (which contains the PDF certificates) is pushed far out to the right (beyond the rest of the layout) which makes it impossible for the cells in this column to be edited. This also happens in Dreamweaver; the table width is 598 pixels but the Display width (in parenthesis in Dreamweaver) is 1300 px. Does anyone know why the Display width, which I assume Contribute is using in Edit mode, is so wide..... and how I can constrain it.
    I have tried adding various table cell widths but to no avail. Help.....
    Many thanks

    This problem has been solved by placing the logo images in their own table cell instead of floating left. The float and adjacent text caused the problem. Thanks to Neil Gibson @cvwcreative who came up with the solution on Twitter.

  • SOLVED: Editing a table cell won't update corresponding ViewObject

    Hi,
    I'm asking for your help.
    I want to update a ViewObject with userinput from jTableCells. The JTable that has been constructed by JDev based on this ViewObject. The attributes of this ViewObject are the result of a SQL query using the NVL() function.
    The Problem is that changing cell values does not update the ViewObject. I guess NVL() causes this. Right?
    As a solution I'd like to add a TableModelListener to the table and take care that changes to cell-data find their way into the right ViewObject attribute. Is this the right solution?
    How can I add a working TableModelListener?
    My try:
    jTable1.getModel().addTableModelListener(new MyTableModelListener());
    The TableModelEvent, that MyTableModelListener gets, always returns "-1" for getColumn(). Why?
    Is there another way to get the current row and column (where the cell-edit takes place)?
    I hardly know anything about ADF, panelbindings and so on, so don't back off with answers that my appear too simple or obvious to you.
    Regards, MaeSiuS
    Message was edited by:
    MaeSiuS

    Hi Frank,
    yes, it is based on EntityObjects.
    For a test, I replaced one of the NVL() based attributes with the plain attribute of the EntityObject, but that had no effect on the update disability.

  • May I create  a  editable table cell in web dynpro java?

    Hi erveryone:
    i can see the readonly property of table in studio,but i can't input data after deployed view to the portal,can i create table include editable cell?
    best regard
    reefish

    Hi,
    When u create the table, choose apply template option>choose table>select the context node to be bound. In the Table Binding Wizard, choose the editor as Input Field.
    Regards,
    Rachel

  • JavaFX2.2 TableView:How to make a table cell be edited without mouse click?

    Hi,
    I've encounter a problem with editable table cells. I'm using the TableView in my project just as the Tutorial on Oracle (http://docs.oracle.com/javafx/2/ui_controls/table-view.htm).
    According to it, I use the setCellFactory method to reimplement the table cell as a text field with the help of the TextFieldTableCell class. However, I found the steps is a little complex to get to the point where the cell can be edited:
    1.Let the table cell be selected by using direction key.
    2.Press “Enter” to converts the cell to a text filed so that it is ready to be edited.
    3.Clicking in the text field allows the contents to be edited
    The problem is step 3, that you must use the mouse to click before you can input data in this table cell.
    So, is there a solution to avoid step 3? That is the text field allows the data inputting when you just press “Enter”(step 2).
    By the way, English is not my native language. Hope I have made myself clear.

    Hi,
    You need to pass the focus to the text field when the startEditing event occurs. In the class that extends TableCell you use for cellFactory:
    public void startEdit() {
    super.startEdit();
    createTextField();
    setText(null);
    setGraphic(textField);
    * put focus on the textfield so user can directly typed on it
    Runnable r = new Runnable() {
    @Override
    public void run() {
    getGraphic().requestFocus();
    Platform.runLater(r);
    }

  • Editable Dynamic Table  Cells

    Hi to all,
    I am using studio creator and mysql.
    I created a Dynamic table for Emp Names and Emp Skills, in that table for Emp Skills i put Text Feild.I am getting text feild in my table.
    here is my doubt
    I am trying to implement the functionality of editing table cells when clicked/doubleclicked on it. I am trying to make the cells editable(textboxes) only after clicking/double clicking them. It should display static text otherwise.
    I am trying to do this one in Javascript onClick event.
    Any sample code I can refer to.Any help is highly appreciated.
    help me
    jo

    Hi friend,
    Thanks for your kind reply.
    what you have send is useful for static table, in static table we can bind any row.
    But in my Module i am using Dynamic table, in that dynamic table for all the rows i need TextFeild.
    when we open the page it has to show static text for all the cells and when we are clicking particular cell that Text feild has to open.
    I dont no how to get Induival id for each and every cell, then only we can bind in dynamic table.
    Any suggestions are welcome.
    Jo

  • Select text of edited table cell

    Hello,
    I would like to have the text selected of a table cell i am editing. When i double click the cell, i can change the content of the cell, but i should manually select the text first.
    I would like to have this text selected automatically.
    Thank you in advance,
    Rene Boere

    Add a focus listener on the text field you are using in the cell editor. When the text field gets focus, tell it to select all of it's text. Something like this maybe:final JTextField tField = new JTextField();
    tField.addFocusListener( new FocusListener() {
        public void focusGained( FocusEvent fe ) {
            tField.selectAll();
        public void focusLost( FocusEvent fe ) {

Maybe you are looking for

  • RFC sender adapter not running

    Hi there, I have following scenario: R3 -(rfc)-> XI -(ftp)-> LEGACY. In R3, i created a RFC DESTINATION (type T) : with Program_ID & GW options (hostname= R3 hostname & service= sapgwXX where XX means sys number). This RFC currently works!! In the RF

  • Can't Cut & Paste In JavaScript Editor Window

    Can anyone help? Can't cut & paste inside JavaScript Editor Window. I'm using Windows XP Home Edition & Adobe Acrobat 8 Pro

  • Help on loop

    hi. im new in pl/sql. would anyone know how to do a loop in sql plus? im in the process of revoking some 1k+ select rights on a specific user for multiple tables but i dont want to do it manually one by one. here is my revoke sql statement: revoke se

  • ActiveDirectory authentication extremely slow

    I just upgraded to Leopard last night and now all of my AD accounts take an extremely long time to authenticate (~ 2 mins per request). The long pause occurs when I first log in and anytime I need to authenticate the user (e.g. to unlock system prefs

  • InDesign CC 2014, no composite font editor menu

    I installed the new verson of InDesign (InDesign cc 2014 release, KOREAN) yesterday. and composite font editor menu is missing. Is this just a kind of BUG? or there is something I can do to fix this?