Results 1 to 2 of 2
  1. #1
    kmm1977 is offline Member
    Join Date
    May 2010
    Posts
    47
    Rep Power
    0

    Default copy defaulttable mode, two different tables , with diff data

    Following code i try to make a copy of the table which is passed into this method
    But copyPrintingModel , is empty at the the end of the loop but the elementcount is same that in
    the table. i.e. the data is added but the copyPrintingModel looses the data.

    I suppose thats because of , copyPrintingModel.addRow -- perhaps stores only the reference and once that
    goes out of scope , the data is lost

    Please give me tips to avoid that i.e. i want the data to be persistant in copyPrintingModel



    private JTable filterParams(JTable forParamFilter) {

    DefaultTableModel forPrintingModel = (DefaultTableModel) forParamFilter.getModel();
    int i = 0;
    JTable copyParamFilter = new JTable();
    DefaultTableModel copyPrintingModel = new DefaultTableModel();


    while(i < noOfRows){
    copyPrintingModel.addRow((Vector) forPrintingModel.getDataVector().elementAt(i));
    i++;
    }
    }

  2. #2
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Can you explain more how the data is lost?

    But one thing is for sure. One way to solve this thread is by using a File Handling Technique, wherein the data is either solve in a file, database, etc.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

Similar Threads

  1. Replies: 0
    Last Post: 03-18-2010, 05:39 PM
  2. How to use one form to submit data to 2 tables on mysql
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 10-10-2008, 01:41 PM
  3. How to copy and paste data with the clipboard
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:35 PM
  4. Replies: 0
    Last Post: 12-24-2007, 09:47 AM
  5. diff between WML d XHTML
    By bakiya in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 11-02-2007, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •