Results 1 to 3 of 3
  1. #1
    Stephen Douglas's Avatar
    Stephen Douglas is offline Senior Member
    Join Date
    Mar 2010
    Posts
    137
    Rep Power
    0

    Default Updating the existing JTable !

    Hello:) I need to update the JTable i created using the ide which created the code something like. this...

    Java Code:
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                },
                new String [] {
                    "            INVOICE_TYPE", "         CUSTOMER_ NAME       ", "         CUSTOMER_ADDRESS", "               TIN_NUMBER"
                }
            ) {
                Class[] types = new Class [] {
                    java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
                };
                boolean[] canEdit = new boolean [] {
                    false, false, false, false
                };
    
                public Class getColumnClass(int columnIndex) {
                    return types [columnIndex];
                }
    
                public boolean isCellEditable(int rowIndex, int columnIndex) {
                    return canEdit [columnIndex];
                }
            });
            jTable1.setRowHeight(20);
            jScrollPane1.setViewportView(jTable1);
    
            jPanel5.add(jScrollPane1, java.awt.BorderLayout.CENTER);
    
            jTabbedPane1.addTab("EXTEND", jPanel5);
    
            getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);


    Now i need to update this existing JTable.. I have no idea how to do that.. have been trying things.. but none seems to be working..

    please suggest.:confused:
    The Quieter you become the more you are able to hear !

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Java Code:
    table.setValueAt(...);
    Also there is no need for initializing the table like that. Read the DefaultTableModel API for a constructor that allows you to specify the column names and the number of empty rows.

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by Stephen Douglas View Post
    I have no idea how to do that.. have been trying things.. but none seems to be working..

    then read this How to Use Tables (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

Similar Threads

  1. Problem with updating JTable
    By kwaspl in forum New To Java
    Replies: 2
    Last Post: 12-20-2009, 10:41 PM
  2. Get CSS/ Use existing CSS
    By karthikeyan_raju in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 10-21-2009, 05:24 PM
  3. Replies: 0
    Last Post: 08-29-2008, 12:49 PM
  4. Replies: 0
    Last Post: 08-29-2008, 12:16 PM
  5. Updating database table from JTable
    By yesjava in forum New To Java
    Replies: 1
    Last Post: 08-16-2008, 10:16 PM

Posting Permissions

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