Mirror JTable Edits

I have a JTable on one internal frame for data entry. I have a duplicate jTable on a different internal frame. Is there an easy way to mirror the tables as the user edits the cells?

Sure it does. You didn't implement the suggestion correctly.
Create a simple JFrame with two tables and edit either table and the other will be updated automatically.
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 (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.

Similar Messages

  • Preventing JTree updates from uncompleted JTable edits

    Hello there!!
    I have an applet that displays an xml file in a JTree. Each node of the table represents specific elements of the xml file (some are not displayed by design). Also on the applet is a JTable that updates the displayed information depending on what node of the tree is clicked. The information displayed in the table includes names and values of attributes and names and values of xml elements not displayed in the JTree.
    I can edit values in the table and update that tree effectively, so that is not a problem.
    The problem I have is that if the user enters a value in the table, does not press enter and then clicks on another tree node, the entered value is copied into the new tree node. I would like to ignore all values if the user does not specifically press enter.
    I have seen some code examples in previous posts that partially work, but can't get the entered values to be totally ignored.
    I'm currently using the following code to handle the 'didn't press enter' bug.
            table.getEditorComponent().addFocusListener(
                    new java.awt.event.FocusListener(){
                public void focusGained(java.awt.event.FocusEvent e) {}
                public void focusLost(java.awt.event.FocusEvent e){
                    if ( table.getEditingRow() > -1 &&
                            table.getEditingColumn() > -1 ){
                        ((javax.swing.DefaultCellEditor)table.getCellEditor()).stopCellEditing();
            });So my question is: How do I prevent the value entered in the table cell from being copied to the newly clicked on tree node? Any assistance would be great.
    Thanks (even just for reading!)
    Simon
    PS. When are we going to see the back of the stupid censorship in this forum?

    Not too sure if this will help but here goes...
    Normally in a JTable, editing is automatically stopped when the enter key is pressed so there is no need to do anything special there. If you don't want editing to stop when the mouse is clicked elsewhere in the table, what you should do is call cancelEditing() instead of stopEditing() in your focusLost method.
    ;o)
    V.V.

  • Photos on Apple TV.  Portrait with black edges not removable with mirroring or Edit.  Any suggestions?

    I use Apple TV to show photos to friends.  However, if the photo is in Portrait format there are large black sections at each side on the the TV screen.  Mirroring or Edit do not remove these black edges even though on the iPad I can  change the set up.  Any suggestions please?

    Mirroring mirrors the 4:3 shape of the new iPad screen - the best output you'll get will be 4:3 filled with black at the sides.
    Try standard Airplay instead of mirroring (which is not available on the iPad 1).

  • JTable edited data doesn't appear in the same time

    Hi
    i have aserious problem JTable edited data doesn't appear in the same time imust tom minimize the frame and maximize it to see the table modified what is the reason?

    Quit multi-posting the same question every time. You asked this same question 3 hours ago:
    http://forum.java.sun.com/thread.jspa?threadID=729894
    The last time you posted the same question within two minutes of one another:
    http://forum.java.sun.com/thread.jspa?threadID=729202
    http://forum.java.sun.com/thread.jspa?threadID=729200
    Not only that, you never bother to reply to your postings to indicate whether the advice given was helpfully or not. This is commonly known as thanking people for the time spent helping your.
    Learn to use the forum correctly or you will be on your own in the future.

  • Make my JTable editable

    in mu Jtable when i click a cell and change the value inside, the JTable does NOT save the value, (when i come back to the Jtable i find the OLD value and not the new one),
    Please help me to make my JTable editable, so when i change the value in any cell this value is saved when i leave this cell...
    Thanks to any help

    >
    in my Jtable when i click a cell and change the value inside, the JTable does NOT save the value, Kindly show your code here...
    When i come back to the Jtable i find the OLD value and not the new one)you came back from where ? are you starting the application again or just switching between forms?
    Please help me to make my JTable editable, so when i change the value in any cell this value is saved when i leave this cell...Do u want to save values permanently ? and please share your code and let use know what exactly you wanna do.

  • How to set jtable editable?

    how to set jtable editable?

    Hi,
    Doubleclick on a particular cell to get the cellEditor for editing.
    Cheers :)
    Nagaraj

  • How to make JTable editable by me but not by the user?

    Hi. I am doing an application to show data in a JTable.
    I need to update the data but do not want the user to change the data.
    Could somebody tell me how to do it?
    Thanks a lot!

    Yes, the above solution is clean. To add a little bit, if you donot want to have a JDialog to your application, just check for the password that is sent in an argument at the start of the application.
    java MyApp <password> // to be run by you
    java MyApp // to be run by user
    This would check the password and then sets the edit mode for the table. (But mind you, this can be done only at the start). If you want to determine the editing mode during the runtime, then you have to go for a login dialog. But, as far as I can imagine, you develop the application and will give it to the user. Is that correct?
    Thanks,
    Kalyan

  • JTable edited cells, in bold text

    Hi
    I'm using a JTable to edit some data. And just wondering if I can realze the data edited. Putting some text bold, or whatever in the render.
    Is it posible to get the component of just a cell and set up some properties?
    Thanks in advance.

    JLabel can handle some html markup, for example:
    JLabel l = new JLabel();
    l.setText("<html><i>italics</i> <b>bold</b> <u>underline</u></html>");The default cell render is derived from JLabel, so you can:
    1. Contrive to have your data object's toString methods produce such html
    2. or subclass DefaultTableCellRenderer and override setValue.
    3 etc...

  • JTable  Edit Problem

    Hi All
    I dont want user to Edit the JTable..
    How to do this ?
    Thx in Advance
    Vipin

    you need to provide a readonly TableModel (isCellEditable has to return false)
    Check this:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data
    Torsten

  • JTable edits wrong cell on mouseclick

    I am using an editable JComboBox as my cell editor. When the user is editing a cell and clicks on another cell with the mouse, the value of the cell they were editing is inserted into the cell that they clicked on. Can anyone please help me. Thanks.

    The Swing tutorial has a working example:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#combobox

  • Updating resultsets using vectors in editable JTables

    Ok i am currently retrieveing my result from a vector of vectors from a query:
    public void presentResultSet (ResultSet rs)throws SQLException {
    Vector dataVector=new Vector();
    try
    {if (!rs.next())
        JOptionPane.showMessageDialog(null, " No records for student" );
      else {
        do{
         Vector rowVector=new Vector();
         rowVector.addElement(rs.getString("studentID"));
         rowVector.addElement(rs.getString("moduleID"));
         rowVector.addElement(rs.getString("examMark"));
         dataVector.addElement (rowVector);
        }while(rs.next());
    } tab.setData(dataVector);
    dataTableScrollPane.setViewportView(dataTable);}
    catch (Exception f){ System.out.println (f.getMessage());
    This method is fine actually as it displays the results onto my GUI. But problem is, i want to add another feature of the system where users can click on any cells in the JTable, edit it and JTable will be able to help me update it onto my tables in mysql.
    I have set the public boolean iseditable into true.
    but can anyone tell me how to write the public void setValueAt method ? how to retrieve that information that the user type into the particular cell and update it onto the database ? Please help !

    Ok I assume because your using a JTable that you are using your own TableModel because the DefaultTableModel usually won't do everything you want. So if your not extending DefaultTableModel you need to start there.
    In your Table model you need a method called setValueAt which will overide the DefaultTableMode.setValueAt().
    Your TableModel's setValueAt() will get called by the table Cell Renderer when ever a cell is edited.
    So to break down setValueAt(Object aValue,int aRow,int aColumn)
    Object aValue = is whatever the user has entered in the Cell. Now its an Object and not a String because you can have all sort of things in a JTable Cell such as checkboxes,buttons, etc.
    The int Row and int Column are pretty self explanitory.
    I don't know what your table looks like but lets say you have have 3 columns
    StudentID,ModuleID,ExamMark you could do something like this
    public void setValueAt(Object aValue,int aRow,int aColumn)
            // In your table model there should be some Vector that contains your other 
            // Vectors. In this example "rows" is that Vector
           // this assigns rowVector the Vector of Columns at the row
           // that was edited by the user in the JTable. It should contain the 3 columns
           Vector rowVector = (Vector)rows.elementAt(aRow);
            // this will overwrite the current value at that column
            rowVector.setElementAt(aValue,aColumn );
            // you may need to cast aValue into whatever Object you plan on storing probably a string
            // ie. rowVector.setElementAt((String)aValue,aColumn );
    } Your Table Model should now contain the new value in its rows Vector all you have do is add someway to save that new Vector back into the Database.
    Hope this helps I didn't compile it but I think it will work or at least give you a better understanding....
    Or maybe I confused you more.
    Good Luck
    Justin

  • Editable JTextField in JTable

    Hi,
    My table has 4 columns and n number of rows (coming from Database), one of them is Editable column. I have a JTextField in Editable Column. I want to save changes to database when user is finish editing that column. the way I am saving all data is when user presses "Save" I read all data from Jtable editable column, and save changes. Only problem is that which ever row was user working on last...changes are not registered...for changes to be registerd..user have to select different row..then and only then last working cell/row data gets saved. How do i make sure that all changes are registerd when user presses "save".
    to get value at editable jtextfield column i am using...
    int row = myJTable.getSelectedRow();
    Object jtf_Value = (CustomModel) myJTable.getModel().getValueAt(row, 1);
    by this method, jtf_value returns data before any editing.. (Editiing cell shows new edited value...
    ex. if I edited that column..with 'test data 123'
    and before eidition value was 'testing'
    jtf_Value returns 'testing' Not 'test data 123'
    thank for help in advance.

    The DataModel isn't updated until focus is moved to a different cell. To force updating of the DataModel add the following code at the start of your Save action:
    if ( table.isEditing() )
         int row = table.getEditingRow();
         int col = table.getEditingColumn();
         table.getCellEditor(row, col).stopCellEditing();
    }

  • Edit a JTable cell by clicking at it once - is it possible?

    If I want to edit a cell in a JTable, I have to doubleclick on it. Is it possible to set the JTable cells to be in edit mode by just clicking at the cells once?

    Did you search the forums?? How about something like "jtable-edit-single-click".

  • Set a focus in an editable jtable

    Please i have a jframe which contains a jtable editable. J programmed it in such way that when I click on TAB the following cell will be selected.
    Although that this cell will be selected whereas the focus does not viewed;
    When I type some characters by the keyboard they will be taken into account by the cell,
    I would like to see the focus as if i click by the mouse on the cell.
    Thanks you for your help

    Swing related questions should be posted in the Swing forum.
    Maybe my reply here is what you are looking for:
    http://forum.java.sun.com/thread.jspa?threadID=509229&tstart=0

  • Odd region edit behavior

    Hi all,
    I encountering a small issue in Logic Pro 8.0.2.
    I record an audio track maybe 4 bars. After listening I decide I only want the second two bars. I used to be able to (in express 7.2) just drag the file to the beginning of the 3rd bar and that would be that. Now what happens is that the entire file moves and when I let go of the mouse the file snaps back to it's original position.
    At the same time that the file "snaps" back into place, the mixer window that is on my second monitor changes to a different view of my fader, instead of mirroring my edit window plus sends and main outs it shows only the faders that relate to the track I am trying to edit.
    In short the only way to remove the first two bars of my edit is to use scissors tool and delete the region.
    I know this must be a simple case of a setting some where, but what and where?
    Thank you in advance for any help and clues,
    Jay

    Thanks for the heads up,
    Thats what I thought at first and I wish it was but unfortunately the [ is present when I try to do this in Logic.
    Most perplexing,
    Any other ideas very welcome,
    Thanks again,
    Jay

Maybe you are looking for

  • Update 7 takes 2 minutes to Open Project

    Hi, After I upgraded to Upgrade7, it now takes more than 2 minutes to open my project. This was not happening earlier. The performance is fine once the project is open, though. Would apreciate advise. Regards Haroon

  • Would like to clear my Itunes from all music and transfer my music and libraries from my ipad to my computer/itunes.

    I would like to delete my music on itunes and transfer all music and libraries from my ipad to my computer/Itunes. I´m doing that because I updated Itunes on my computer, didn´t like the new version, delete it, went back to an old version of itunes b

  • MIGO screen from PO History Tab

    Hi Experts, Currently if we click on GR document in the PO History tab, it will take to Material Document Display.  Is there any possibility to take to MIGO screen so that if user wants to cancel the GR document he can cancel it. regards, Mallik

  • How to remove wrong thumbnail picture associated with MP3/WMA file?

    Win7 associates those little thumbnail sized pictures to some mp3/wma files I have (inside Music library), but some some pictures are wrong. How to "dissociate" those wrong pictures? Furthermore, Win7 seems to fill in informations to music files but

  • Wireless Bridge Deauthenticationing

    I have a customer with a point to point wireless bride using two 1240 ap's.  Every 12 minutes or so, the MAXRETRIES: maximim is reached, the client is deauthenticated becasue the previous authentication is not valid.  The client then reassociates.  T