Edit table cells

i have edited the setValueAt method of the TableModel interface to enable editing of cells in my JTable - in-situ. This works fine. However, i would like it so that when any change is made to the table data, it is automatically sorted depending on how it was sorted before the change was made. i have:
public void setValueAt(Object aValue, int row, int col) {
        if (col == 0) {
            bookList[row].setBookNumber(Integer.parseInt((String)aValue)); // Populates cell with new book number
            if (lastSort == "number") {
                listByNumber();
        } else {
            if (col == 1) {
                bookList[row].setTitle((String)aValue); // Populates cell with new book title
            } else {
                if (col == 2) {
                    bookList[row].setAuthorPrename((String)aValue); // Populates cell with new author prename
                } else {
                    bookList[row].setAuthorSurname((String)aValue); // Populates cell with new author surname
    }i would put more if statements in later for different sort methods but at the moment ill just stick with one. My problem is that the array is being sorted correctly, but the table doesn't update automatically to show the change. what DOES happen - is when you click on each row of the table, it changes until it is in the correct order. this leads me to think that the sorting works fine, but somehow my table model isnt reflecting the changes? can any help me update the table in real time?

no luck :( i tried:
   public void setValueAt(Object aValue, int row, int col) {
        if (col == 0) {
            bookList[row].setBookNumber(Integer.parseInt((String)aValue)); // Populates cell with new book number  
            listByNumber();
            fireTableDataChanged();and extended AstractTableModel but it still didnt work. is there anything else i would need to do?

Similar Messages

  • 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

  • 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 ) {

  • Edit table cells in Dreamweaver 8

    In Dreamwever MX2004 if you have a 1 row, 2 column table, I
    can enter text in the left cell and not affect the right cell,
    otherwords, I can have text in the right cell and it does not move
    if I do a carrage return in the left cell.
    However in Dreamweaver 8 with the same situation, the text
    line in the right cell moves down one line for each carrage return
    in the left cell. Dreamweaver 8 does not leave an editable area
    abovr the text of the right cell so you can't backspace the text
    back to the top of the cell, thus, I can't have any alignment
    between the two cells.
    Any ideas on how to make Dreamweaver 8 behave the same as
    Dreamweaver MX2004
    Cheers,
    Linus Sagadore

    as a pure guess, it's got to do with the align attribute of
    the td tag, or
    the css being used.
    my guess is the code is set to vertically align the contents
    of the right
    cell. When you add content to the left cell, the right cell
    gets taller, so
    the contents of it appear to move down.
    if you're still unclear- please make a page with each
    version, with a table
    that does this, and upload someplace and give a link to the
    uploaded pages.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • 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

  • Auto numbering in an editable table cell

    I created a dynamic table with add/delete row buttons and the second column with text fields.  The text field I want it to initially say <enter task 1> and <enter task 2> and when the user clicks on the add row button it would then say <enter task 3>.  I tried the patterns display but not sure how to get it to do auto numbering.  I also tried the formcalc script $ = Concat ("<Task", $.parent.index + 1, ">").  This seemed to work with the auto numbering but then I couldn't actually edit the boxes.  Any help on this would be greatly appreciated...thank you.

    Did you make the field as ReadOnly or Protected?
    Also make sure where did you place your code? If it is in the Calculate event, the default is "Calculated - ReadOnly".
    Placing the code in Initialize event might help.
    Thanks
    Srini

  • Editing table cell data can be difficult

    There are times I click and click on a cell to get it to edit.  Is there any trick to making the cells more editable?  There are times I have to click 10 times to get the cell to edit.
    Matt
    Message Edited by mfitzsimons on 06-01-2006 12:28 PM
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
    Attachments:
    profilesUpdateAll.vi ‏22 KB

    Hi matt,
    for me it works just fine (using LV 8.0.1). Maybe it's because you only have to click once (no dbl-click) and wait a bit, then it changes to editable. On Dbl-click, nothin happens.
    be cool.
    dave
    Greets, Dave

  • Editing table cells

    Hi! Does anyone know a good guide or a good tutorial to undestand the setting up of the tableCells of a tableView? How to work with them at all, chaning colors, adding different size and color text, images or similar?
    Thank you

    What types of edits are you doing? and what is the source of the table (or its original formatting)?

  • 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

  • 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

  • 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.

  • 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.

  • ABAP WD: Editable Table - Identifying changed cells

    Hi,
    I have a requirement to create editable table. I have been successful in doing so. However, I have the following requirement.
    1) In case the user changes a particular column in a particular row, how will I get to know only that particular row/column  is changed?
    For ex:If the table has 20 rows, user changes the second column in 18th row without selecting that row, then how can I identify that only second column of row no 18 has been changed. Without this being accomplished, everytime user makes changes I have to delete these 20 rows and re-insert these 20 rows into the database.
    I checked that ALV provides classes for identifying changed rows but I want to use table because I need to use pop-in.

    Hi Maksim Rashchynski,
    Thanks for the reply.
    1) I wanted a way to know the changed columns/rows by a user in an editable table.
    For ex: In ALV, event ON_DATA_CHECK is triggered when data that has been changed is checked in an editable ALV output and T_MODIFIED_CELLS gives Position and values of cells after the change has been made. DO we have something like that in editable table?
    2) onLeadSelect is fired only when the lead selection happen.
    For ex: When you show editable table with say 20 rows, the first row is selected by default. Now user can change say 2nd column in 2nd row without changing the lead selection. In such a case, onLeadSelect would not be of help.
    Regards,
    Srini.

  • Stop editing a table cell

    Hi,
    I want to edit a cell of a table, so I have this:
    public class AttributeFrameCellEditor
         extends DefaultCellEditor
         public AttributeFrameCellEditor (final JTextField tf, final String aoName, final String attName)
              super (tf);
              delegate = new EditorDelegate()
                   public void setValue (Object param)
    // manipulate data in an internal frameEverything's fine, but how can I tell (Whom?) sth like editingStopped?
    Now I have to select another row to get rid of the Textfield.
    Looking forward to your help!

    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

Maybe you are looking for

  • How to connect theUSB-6009 with Matlab?

    Hello, I have a project to. For this project I have to send signal from Matlab to the USB-6009. After the signal go trough a filter and come back to the USB-6009, so I also have to recieve informations to Matlab from the USB-6009. Is there anybody wh

  • [SOLVED] Error Message: jshon: invalid option -- 'Q'

    I'm seeing this message a lot. (Mostly during the boot verbiage.)  I have zero idea what it means--or how to remedy whatever the problem is.  Dr. Google hasn't been too much help so far.    Any ideas? Last edited by wilberfan (2011-08-12 16:48:24)

  • Updating new PID of thr process in SAP MMC

    Hello, There was an abrupt shutdown in process of rslgsend and igs* I have manually restarted the process and it is working on SAP level,although as a new process is started its PID is not updated in SAP MMC and hence it is displayed in grey status e

  • The files appear to be unsupported or damaged

    I can drag these same pictures to Lightroom and work on them but I can't import them for catalog.  Any suggestions.  They preview in any viewer but I can't import for catalog.

  • Problem when trying to edit an answer in thread

    Hi, in this thread: Call BAPI_INCOMINGINVOICE_PARK park document local amount is always zero although the answer is formatted and the preview is displayed correctly, the formatting is not displayed in the real answer. Could someone have a look at thi