JTable Data

First...new to Java....I have a form which collects information, all address type info. There are 6 different types of addresses. There are 24 possible address fields. The address types all collect similar info...but not the same. The 24 fields is an aggregation of all address fields. For the fields that dont pertain to the tab I am i just set the value to null. Each address type is on its own tab. I have assigned a prefix to each tab like following: tab1 tab2 etc. What I want to be able to do is to collect the information on each tab and assign it to a row in a jtable. the rows would be filled even if it is only null data. I also would want to take the data from the jTable and repopulate the tabs...assuming of course, the table is still in memory.
So..based on the prefix I assign I want the forms/jTable to be smart enough to save the values to the right row in the table and to repopulate itself based on the same prefix. Is this doable?
Thanks

Please don't repeat your post. Just bump the old one (add a reply so that it moves to the top of the list):
http://forum.java.sun.com/thread.jspa?threadID=710328

Similar Messages

  • How to Sort JTable data using Multiple fields (Date, time and string)

    I have to fill the JTable data with some date, time and string values. for example my table data looks like this:
    "1998/12/14","15:14:38","Unicorn1","row1"
    "1998/12/14","15:14:39","Unicorn2","row2"
    "1998/12/14","15:14:40","Unicorn4","row3"
    "1998/12/17","12:14:12","Unicorn4","row6"
    Now the Sorted Table should be in the following way:
    "1998/12/17","12:14:12","Unicorn4","row6"
    "1998/12/14","15:14:40","Unicorn4","row3"
    "1998/12/14","15:14:39","Unicorn2","row2"
    "1998/12/14","15:14:38","Unicorn1","row1"
    ie First Date field should be sorted, if 2 date fields are same then sort based on time. if date and time fields are same then need to be sorted on String field.
    So if any one worked on this please throw some light on how to proceed. I know how to sort based on single column.
    But now i need to sort on multiple columns.So what is code change in the Comparater class.
    Thanks in advance.. This is urgent....

    I think your Schedule objects should implement Comparable. Then you can sort your linked list using the Collections.sort() method without passing in a Comparator.class Schedule(Date date, String class) implements Comparable
      public void compareTo(Object obj)
        Schedule other = (Schedule)obj;
        return date.getTime() - other.getDate().getTime();
    }

  • Save a JTable (data+settings) ?

    I want to save a complete JTable.
    In my JTable I changed all,
    that means I changed the hight of a row and the length from a coloumn to have the best view of the data.
    I want to save the table with this changes.
    I used for the JTable the AbstractTableModel.
    I tried to save and load the AbstractTableModel Object with the ObjectOutputStream but it doesn't worked.
    Only the Coloumnames was showing, but that's all.
    I hope somebody can help me
    Andreas

    Your post gave me an idea and I didn't think it would work, but it seems to have done just fine. There has to be something wrong with this. It's too bizarre.import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Test3 extends JFrame {
      String[] head = {"One","Two","Three"};
      String[][] data = {{"R1-C1","R1-C2","R1-C3"},
                         {"R2-C1","R2-C2","R2-C3"},
                         {"R3-C1","R3-C2","R3-C3"}};
      JTable jt = new JTable(data, head);
      byte[] bytes;
      Container content = getContentPane();
      int count = 0;
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        JPanel buttonPanel = new JPanel();
        content.add(buttonPanel, BorderLayout.SOUTH);
        JButton save = new JButton("Save"), restore = new JButton("Restore");
        buttonPanel.add(save);
        buttonPanel.add(restore);
        save.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            try {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(baos);
              oos.writeObject(jt);
              oos.flush();
              oos.close();
              bytes = baos.toByteArray();
              content.add(new JPanel(), BorderLayout.CENTER);
              content.validate();
            } catch (Exception e) { e.printStackTrace(); }
        restore.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            try {
              ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
              ObjectInputStream ois = new ObjectInputStream(bais);
              JTable newTable = (JTable)ois.readObject();
              content.add(new JScrollPane(newTable), BorderLayout.CENTER);
              content.validate();
            } catch (Exception e) { e.printStackTrace(); }
        setSize(300,300);
      public static void main(String[] args) { new Test3().setVisible(true); }
    }

  • Java.io.NotSerializableException when overwrite the JTable data into .txt file

    hi everyone
    this is my first time to get help from sun forums
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
    but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    the following is my code...some of it i create it with the GUI netbean
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    this is the code that suspect maybe some error here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2);
                   oos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                   return;
              System.out.println("JTable correctly saved to file " + filename);
    }the full code will be at the next msg

    this is the part 1 of the code
    this is the full code...i had /*....*/ some of it to make it easier for reading
    package gui;
    import javax.swing.*;
    import java.io.*;
    public class timetables extends javax.swing.JFrame {
        public timetables() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            buttonGroup1 = new javax.swing.ButtonGroup();
            buttonGroup2 = new javax.swing.ButtonGroup();
            buttonGroup3 = new javax.swing.ButtonGroup();
            buttonGroup4 = new javax.swing.ButtonGroup();
            jTextField1 = new javax.swing.JTextField();
            jLayeredPane1 = new javax.swing.JLayeredPane();
            jLabel6 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTable2 = new javax.swing.JTable();
            jScrollPane4 = new javax.swing.JScrollPane();
            jTable3 = new javax.swing.JTable();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
    /*       org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
            String filename1 = "studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable2 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable3 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            jTable2.setRowHeight(20);
            jTable3.setRowHeight(20);
            jScrollPane3.setViewportView(jTable2);
            jScrollPane4.setViewportView(jTable3);
            jTable2.getColumnModel().getColumn(4).setResizable(false);
            jTable3.getColumnModel().getColumn(4).setResizable(false);
            jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
            jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
            jTextField1.setText("again n again");
            jLabel6.setText("jLabel5");
            jLabel6.setBounds(0, 0, -1, -1);
            jButton2.setText("jButton2");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
          

  • Java.io.NotSerializableException when overwrite the JTable data into .txt

    hi everyone
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable
    will be showing out with the data that been save in the studio1.txt
    previously,
    but after i edit the data at the JTable, and when i trying to click the
    save button, the error had been showing out and i cannot succeed to
    save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    the following is my suspect code
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename1 = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename1));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2.getModel());
                   oos.flush();
                   oos.close();
                   fos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                            e.printStackTrace();
                   return;
              System.out.println("JTable correctly saved to file " + filename1);
    }this is the reading code
    String filename1="studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   TableModel model = (TableModel)ois.readObject();
                    jTable3.setModel(model);
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
              }Edited by: Taufulou on Jan 8, 2009 11:43 PM
    Edited by: Taufulou on Jan 8, 2009 11:44 PM
    Edited by: Taufulou on Jan 8, 2009 11:45 PM

    is this the code u mean?
    i had put this code inside it but the problem still remain the same
    if (jTable2.isEditing()) {
                jTable2.getCellEditor().stopCellEditing();
            }i had found a new thing that when i just double click the cell without change any data inside the table
    and click the button "Save". the same exception which is
    java.io.NotSerializableException: java.lang.reflect.Constructor
    will come out again.

  • Write jTable data into a file

    Hi All ,
    I am preparing a Java Swing GUI , In this i have a jTable . Whenever a user writes data into that jTable , the written data should fall in a file .Please tell me the code how to write this jTable data into a file .
    Any help will be highly appreciated.
    Thanks,
    Rajesh

    Don't do that. Why would you want to rewrite the entire file (since you can't really selectively edit it) if just storing (maybe serializing) the table's data model when the application is exiting or an explicit saving is requested by the user would be enough?

  • JTable data back-up (re-visited)

    Hi!
    I need to persist the data in my jTable rows and columns. Right now I get and set them with java preferences with two x and y loops ... this works fine.
    but ..... is there a way to save to a file the jTable row and column data without first extracting the row and column data cell for cell?
    ie; to serialize only the cell data?

    Thanks!
    Is there an example code for me to look at? (didnt see much on Google so far)

  • JTable data back-up

    Hi!
    I'm currently using preferences API to back-up my jTable (lots of coding).
    can I back up my entire jTable with single serialization file?
        try {
          FileOutputStream fos = new FileOutputStream (jTable);
          ObjectOutputStream oos = new ObjectOutputStream (fos);
          oos.writeObject (table.ser); 
          oos.flush();
          oos.close();
              } catch (IOException e) {
                e.printStackTrace();
    }

    can you show me an example of how that is done?Sorry, I don't feel like writing the code, but I
    would guess that opening a file, writing a loop,
    write some data, and close the file is done inless
    than 30-40 lines of code.
    KajWhen you say "write a loop" do you infer that the
    data must be extracted by row and column coordinates?Yes

  • Implement paging (prev/next) for jtable data obtained from database

    Hello all, first time poster and relative newbie to java.
    I am trying to learn java and in the process have stumbled upon this issue.
    I have searched through the forum as well as googled my way around for answers. And though I am more informed than I was, I still am a little stumped.
    I would like to implement a table that pulls data from a database (mysql), limits the results, and include prev/next buttons to traverse through the records.
    I think this involves writing my own AbstractTableModel. And I have seen some examples as such. But could use a little more help.
    I will always be pulling 10 rows, but the columns will change depending on query I am using so implementing a more generic set of methods would be great.. To be specific...
    Table: users
    Columns: userid, ufname, ulname, utype, ustatus, etc....
    For selection purposes I only need to show: userid, ufname, ulname. So I figure I write a query like:
    select userid, ulname, ufname from users limit index, 10
    Where index tells the query where to start from then use the results to populate the jtable. I can do this statically but do not quite understand how to implement the next/prev buttons so that the table pulls the next or previous set of data.
    If this can happen without the need to repaint/refresh the frame that would be great.
    sudo code (with comments) would be ok, but a basic working example of this would be even better.
    thank you in advance, if more information is required please let me know.

    tumbleweeds roll by...........

  • Problem dispaying jtable data

    Hello All, and thanks for any help.
    I have a jTable that is populated with an array of strings. During the
    course of the program these values get changed depending on the selection of
    a jcombobox. What I have noticed is that I am unable to set the initial
    values back in the table. I can set the values to any other of my data
    string arrays except the initial ones. I am using the setValue method of the
    table model. Here is the jtable tablemodel constructor:
    class MyTableModel extends AbstractTableModel {
    String[] columnNames = {"Nom. dia.","Dia. (in)",
    "Instal. Cost",
    Object [][] data = pipeschedlight;
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    * Don't need to implement this method unless your table's
    * editable.
    public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    //if (col < 2) {
    //return false;
    //} else {
    return true;
    * Don't need to implement this method unless your table's
    * data can change.
    public void setValueAt(Object value, int row, int col) {
    if (DEBUG) {
    System.out.println("Setting value at " + row + "," + col
    + " to " + value
    + " (an instance of "
    + value.getClass() + ")");
    data[row][col] = value;
    fireTableCellUpdated(row, col);
    if (DEBUG) {
    System.out.println("New value of data:");
    printDebugData();
    private void printDebugData() {
    int numRows = getRowCount();
    int numCols = getColumnCount();
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + data[i][j]);
    System.out.println();
    System.out.println("--------------------------");
    Cheers,
    Jacques

    Sorry, this is the wrong forum, I am going to transfer this to the swing forum.
    Jacques

  • Edit JTable Date Cell, press Enter, the Time Cell changes to GMT time!

    Has anyone seen this strange behavior? I try to edit a Date Cell in JTable (orig. value 10/02/2000) and change it to (10/03/2000), I press Enter. But, the value of my Time Cell in the next column, same row which I never edited (orig. value 00:05:00) changes to approximately my system time in GMT (16:28:48).
    This is an excerpt from my TableModel which get called from setValueAt():1734 javax.swing.JTable, JTable.java. In the code below, the debug statement prints out:
    row, col = 0,0
    Value in SubTableModel = 10-02-2000 16:28:48
    Value should be "10-02-2000" since I did not edit the time cell at all. And why is row and col both zero?
    public void setValueAt(Object value, int row, int col) {
    try {
    ((ITableCellAdapter)adapters.get(col)).setData(getRow(row),col);
    System.out.println("row, col = " + row + col);
    System.out.println("Value in SubTableModel = " + value.toString());
    ((ITableCellAdapter)adapters.get(col)).setValue(value);
    catch (PropertyVetoException badSet) {
    System.out.println("could not set value");
    fireTableCellUpdated(row,col);
    How can I force it to set the date cell's new value only and leave the time cell alone?
    I've also seen that sometimes my date entry gets lost, the old value still showing, what am I doing wrong? I've seen a bunch of bug parade listings about terminating edits within a JTable being buggy, is this related?
    Any help on this is most appreciated!

    Did you find the solution to yuor problem?
    Has anyone seen this strange behavior? I try to edit
    a Date Cell in JTable (orig. value 10/02/2000) and
    change it to (10/03/2000), I press Enter. But, the
    value of my Time Cell in the next column, same row
    which I never edited (orig. value 00:05:00) changes to
    approximately my system time in GMT (16:28:48).
    This is an excerpt from my TableModel which get called
    from setValueAt():1734 javax.swing.JTable,
    JTable.java. In the code below, the debug statement
    prints out:
    row, col = 0,0
    Value in SubTableModel = 10-02-2000 16:28:48
    Value should be "10-02-2000" since I did not edit the
    time cell at all. And why is row and col both zero?
    public void setValueAt(Object value, int row, int
    nt col) {
    try {
    ((ITableCellAdapter)adapters.get(col)).setData(getRow(
    ow),col);
    System.out.println("row, col = " + row +
    + row + col);
    System.out.println("Value in SubTableModel = "
    del = " + value.toString());
    ((ITableCellAdapter)adapters.get(col)).setValue(value)
    catch (PropertyVetoException badSet) {
    System.out.println("could not set value");
    fireTableCellUpdated(row,col);
    How can I force it to set the date cell's new value
    only and leave the time cell alone?
    I've also seen that sometimes my date entry gets lost,
    the old value still showing, what am I doing wrong?
    I've seen a bunch of bug parade listings about
    terminating edits within a JTable being buggy, is
    this related?
    Any help on this is most appreciated!

  • JTable data changed

    Hello,
    I have a JTable, there i stored values form database.
    I also have a "Save" button in the form.
    When user opens o form he saw data form database in JTable. I need a listener is user has changed some value i a JTable. If yes i need to enable save button.
    Can somebody point me to some value change listener example o give some advice
    Thanks a lot

    You can provide your own text field component to the DefaultCellEditor. Then you can add a key listener to that text field:
        JTextField text = new JTextField();
        text.addKeyListener( new KeyAdapter() {
          public void keyTyped( KeyEvent e ) {
            // Enable your save button here.
            saveButton.setEnabled( true );
        DefaultCellEditor e = new DefaultCellEditor(  text );
        // Then set the cell editor into the JTable however you prefer.
        // I usually overwrite JTable's getCellEditor() and return the
        // custom cell editor to do this.-Mike

  • Problem in populating jtable data from database

    hi,
    i am using JTable to retrieve data from database and show it in table. JTable
    is working fine with static data. but while retrieving from databse its giving a NullPointerException at getColumnClass() method. Below is complete source code. plzz help.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.sql.*;
    import javax.swing.table.*;
    /*jdbc connection class*/
    class connect
    Connection con;
    Statement stat;
    public connect()throws Exception
    Class.forName("org.postgresql.Driver");
    con=DriverManager.getConnection("jdbc:postgresql://localhost/dl","dl","dl");
    stat=con.createStatement();
    public ResultSet rsf(String rsstr)throws Exception
    ResultSet rs=stat.executeQuery(rsstr);
    return rs;
    public void upf(String upstr)throws Exception
    stat.executeUpdate(upstr);
    class MyTableModel extends AbstractTableModel
    private String[] columnNames = {"name","id","dep","cat","rem","chkout"};
    Object[][] data;
    public MyTableModel()
    try{
    connect conn=new connect();
    ResultSet rs3=conn.rsf("select * from usertab");
    ResultSetMetaData rsmd=rs3.getMetaData();
    int col=rsmd.getColumnCount();
    int cou=0;while(rs3.next()){cou++;}
    data=new Object[cou][col];
    System.out.println(cou+" "+col);
    ResultSet rs2=conn.rsf("select * from usertab");
    int i=0;int j=0;
    for(i=0;i<cou;i++)
    rs2.next();
    for(j=0;j<col;j++)
    data[i][j]=rs2.getString(getColumnName(j));
    System.out.println(data[0][2]);
    }catch(Exception e){System.out.println("DFD "+e);}
            public int getColumnCount() {
                return columnNames.length;
            public int getRowCount() {
                return data.length;
            public String getColumnName(int col) {
                return columnNames[col];
            public Object getValueAt(int row, int col) {
                return data[row][col];
           public Class getColumnClass(int c) {
              return getValueAt(0, c).getClass();
            public boolean isCellEditable(int row, int col) {
                if (col < 2) {
                    return false;
                } else {
                    return true;
            public void setValueAt(Object value, int row, int col) {
                data[row][col] = value;
                fireTableCellUpdated(row, col);
    class MyFrame extends JFrame
    public MyFrame()
         setSize(600,500);
         JPanel p1=new JPanel();
         p1.setBackground(new Color(198,232,189));
         JTable table = new JTable(new MyTableModel());
         table.setPreferredScrollableViewportSize(new Dimension(500,200));
         table.setBackground(new Color(198,232,189));
         JScrollPane scrollPane = new JScrollPane(table);
         scrollPane.setBackground(new Color(198,232,189));
         p1.add(scrollPane);
         getContentPane().add(p1);
    /*Main Class*/
    class test2
         public static void main(String args[])
         MyFrame fr =new MyFrame();
         fr.setVisible(true);
    }thanx

    hi nickelb,
    i had returned Object.class in the getColumnClass() method. But then i
    got NullPointerException at getRowCount() method. i could understand that the
    main problem is in data[][] object. In all the methods its returning null values as it is so declared outside the construtor. But if i declare the object inside the constructor, then the methods could not recognize the object. it seems i cant do the either ways. hope u understood the problem.
    thanx

  • JTable data persistance problem

    i have large number of rows to be displayed in a JTable , the user can configure the number of rows he
    wants to view , the table will have next and previous buttonns to navigate to the different pages , i have
    solved the problem by reading data from. a 2 dimensional object array according to the user choice , the
    next and the previous buttons are working , but the problem is there is no data persistance for example if
    the user deletes 2 rows from the 1st page and goes to the 2nd page , when he comes back again to the 1st
    page the deleted elements are still there. I am using an my own model which implements abstract table model.It would b gr8 if any one can send the code.Thanks in advance.

    Are you removing the rows from your Object Array?
    if so, you are rigth now, you must to use at you model
            fireTableDataChanged();When you change data from your object array.
    Hope this helps...

  • Simple question concerning "persisting JTable data?"

    Hi fellow bloggers,
    I couldn't find this info in the Sun JTable tutorial. The tutorial explains how to update a cell in a JTable, but it doesn't suggest a method for persisting the "row" once it has been modified. Furthermore, the JTable tutorial states the following in the leading summary:
    "JTable does not contain or cache data; it is simply a view of your data."
    Does this mean that the data structure which is used to populate the JTable must be updated on a row by row basis, as well as updating the JTable itself? Isn't there some way to select a row on the JTable, update the row of data, and then port the data in a row of cells to a completely separate data structure?
    Thanks.

    If you want your data cached or persistent, you do that in the TableModel. DefaultTableModel will already be persistent. What they mean in that quote is that whenever the JTable needs a value for cell it queries the TableModel for the value.
    I'm not sure why you want/need/care to port the data in a completely separate data structure, but sure... you can do that. Create a class and feed the data into it however you please, that'll be that.

  • JTable data entry

    Hi,
    When I asked my question in the "New to Java" forum, I was redirected here. Here is my question:
    I've just created my first JTable (inside a JScrollpane, inside a JPanel, inside a JFrame). It seems to work ok, except that when I type data into cells, the data in the last cell I edit isn't saved to the model when I "leave" the table unless I hit return after typing it in or click somewhere else in the table before "leaving." And occasionally, I forget to do that. (After all, the table looks right after I'm done typing.)
    When I do leave the table, it's usually to press a JButton that calls a method that does a few calculations and inserts a new blank row into the model at row index 1. Ideally, I'd like that when I hit that JButton, it forces the JTable to update the model with the data typed and pending in the last cell I edited, even if I have forgotten to hit return or click someplace else first.
    Is there a way to force that pending data to be saved?
    Jim

    When you create your table you add the following, then you don't need to worry about using the above code for every component on your GUI.
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

Maybe you are looking for

  • Opening NEF files in Photoshop Elements 7

    Will PE 7 open NEF files from Nikon D200, without additional plug-ins? I'm using Windows XP Home Edition and Nikon View to transfer images.

  • Materialized View with column based on PL/SQL function returning object

    I have the following problem - it is known that materialized view wants PL/SQL functions used in it to be DETERMINISTIC. And it appears that a function which returns SDO_GEOMETRY cannot be DETERMINISTIC - I can add DETERMINISTIC modifier to my functi

  • MEP process in sap

    hi Can any one give me insights bout MEP( mechanical electrical and plumbing) from SAP SIDE i know from business process side, please give me insights if anybody worked on SAP side regards suresh Edited by: tulasi suresh on Apr 20, 2009 6:11 PM

  • Maximum number of VPLS instances on ME3600X box

    Hi, Does anyone know what is the current maximum number of VPLS instances on ME3600X (Advanced Metro IP Access license)? I've found on one of the old presentations that this was only 26. And why is this limitation present? Best regards, Krzysztof

  • .Mac not updating when publish modified iWed file

    Hi, when I first published my iWeb file to .Mac, it worked. Then I edited the iWeb file and republished, waited a few days, and my .Mac site is still showing the old original iWeb file. - I tried republishing several times (publish to .Mac and publis