Removing rows and inserting new rows with new data in JTAble!!! (Plz. help)

I have a problem, The scenario is that when I click any folder that si in my JTable's first row, the table is update by removing all the rows and showing only the contents of my selected folder. Right now it's not removing the rows and instead throwing exceptions. The code is attached. The methods to look are upDateTabel(...) and clearTableData(....), after clearing all my rows then I proceed on adding my data to the Jtable and inserting rows but it's not being done. May be I have a problem in my DefaultTableModel class. Please see the code below what I am doing wrong and how should I do it. Any help is appreciated.
Thanks
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class SimpleTable extends JPanel{
     /** Formats the date */
     protected SimpleDateFormat           formatter;
/** variable to hold the date and time in a raw form for the directory*/
protected long                          dateDirectory;
/** holds the readable form converted date for the directories*/
protected String                     dirDate;
/** holds the readable form converted date for the files*/
protected String                     fileDate;
/** variable to hold the date and time in a raw form for the file*/
protected long                          dateFile;
/** holds the length of the file in bytes */
protected long                         totalLen;
/** convert the length to the wrapper class */
protected Long                         longe;
/** Vector to hold the sub directories */
protected Vector                     subDir;
/** holds the name of the selected directory */
protected String                    dirNameHold;
/** converting vector to an Array and store the values in this */
protected File                     directoryArray[];
/** hashtable to store the key-value pair */
protected static Hashtable hashTable = new Hashtable();
/** refer to the TableModel that is the default*/
protected MyTableModel               tableModel;
/** stores the path of the selected file */
protected static String               fullPath;
/** stores the currently selected file */
protected static File selectedFilename;
/** stores the extension of the selected file */
protected static String           extension;
protected int COLUMN_COUNT = 4;
     protected Vector data = new Vector( 0, 1 );
     protected final JTable table;
/** holds the names of the columns */
protected final String columnNames[] = {"Name", "Size", "Type", "Modified"};
public SimpleTable(File directoryArray[])
          this.setLayout(new BorderLayout());
          this.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
          (SimpleTable.hashTable).clear();
          formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
          for(int k = 0; k < directoryArray.length; k++)
               if(directoryArray[k].isDirectory())
                    dateDirectory = directoryArray[k].lastModified();
                    dirDate = formatter.format(new java.util.Date(dateDirectory));
                    data.addElement( new MyObj( directoryArray[k].getName(), "", "File Folder", "" + dirDate ) );
                    (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    
               else if(directoryArray[k].isFile())
                    dateDirectory = directoryArray[k].lastModified();
                    fileDate = formatter.format(new java.util.Date(dateDirectory));
                    totalLen = directoryArray[k].length();
                    longe = new Long(totalLen);
                    data.addElement( new MyObj( directoryArray[k].getName(), longe + " Bytes", "", "" + fileDate ) );
                    (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
tableModel = new MyTableModel();
          table = new JTable( tableModel );
          table.getTableHeader().setReorderingAllowed(false);
          table.setRowSelectionAllowed(false);
          table.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
          table.setShowHorizontalLines(false);
          table.setShowVerticalLines(false);
          table.addMouseListener(new MouseAdapter()
public void mouseReleased(MouseEvent e)
     Object eventTarget = e.getSource();
                    if( eventTarget == table )
                         upDateTable(table);
                         table.tableChanged( new javax.swing.event.TableModelEvent(tableModel) ) ;
          DefaultTableCellRenderer D_headerRenderer = (DefaultTableCellRenderer ) table.getTableHeader().getDefaultRenderer();
          table.getColumnModel().getColumn(0).setHeaderRenderer(D_headerRenderer );
          ((DefaultTableCellRenderer)D_headerRenderer).setToolTipText("File and Folder in the Current Folder");
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
this.add(scrollPane, BorderLayout.CENTER);
* Searches the Hashtable and returns the path of the folder or the value.
public File findPath(String value)
     return (File)((SimpleTable.hashTable).get(value));
* This clears the previous data in the JTable
public void clearTableData(JTable table)
     for(int row = 0; row < table.getRowCount() ; row++)
               //for (int col = 0; col < table.getColumnCount() ; col++)
                    tableModel.deleteSelections( row );
          tableModel.fireTableStructureChanged();
          tableModel.fireTableRowsDeleted(0,table.getRowCount());
          //table.getModel().fireTableChanged(new TableModelEvent(table.getModel()));
private void upDateTable(JTable table)
if((table.getSelectedColumn() == 0) && ((table.getColumnName(0)).equals(columnNames[0])))
     dirNameHold =(String) table.getValueAt(table.getSelectedRow(),table.getSelectedColumn());
               File argument = findPath(dirNameHold);
               if(argument.isFile())
                    CMRDialog.fileNameTextField.setText(argument.getName());
                    try
                         fullPath = argument.getCanonicalPath();                          
                         selectedFilename = argument.getCanonicalFile();                          
CMRDialog.filtersComboBox.removeAllItems();
                         extension = fullPath.substring(fullPath.lastIndexOf('.'));
                         CMRDialog.filtersComboBox.addItem("( " + extension + " )" + " File");
                    catch(IOException e)
                         System.out.println("THE ERROR IS " + e);
                    return;
               else if(argument.isDirectory())
                    String path = argument.getName();
                         //find the system dependent file separator
                         //String fileSeparator = System.getProperty("file.separator");
                    CMRDialog.driveComboBox.addItem(" " + path);
          subDir = Search.subDirs(argument);
          /**TBD:- needs a method to convert the vector to an array and return the array */
          directoryArray = new File[subDir.size()];
               int indexCount = 0;
               /** TBD:- This is inefficient way of converting a vector to an array */               
               Iterator e = subDir.iterator();               
               while( e.hasNext() )
                    directoryArray[indexCount] = (File)e.next();
                    indexCount++;
          /** now calls this method and clears the previous data */
          clearTableData(table);     
               (SimpleTable.hashTable).clear();
               //data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
               formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
               for(int k = 0; k < directoryArray.length; k++)
                    if(directoryArray[k].isDirectory())
                         dateDirectory = directoryArray[k].lastModified();
                         dirDate = formatter.format(new java.util.Date(dateDirectory));
                         data.addElement( new MyObj( directoryArray[k].getName(), "", "File Folder", "" + dirDate ) );
                         (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    
                    else if(directoryArray[k].isFile())
                         dateDirectory = directoryArray[k].lastModified();
                         fileDate = formatter.format(new java.util.Date(dateDirectory));
                         totalLen = directoryArray[k].length();
                         longe = new Long(totalLen);
                         data.addElement( new MyObj( directoryArray[k].getName(), longe + " Bytes", "", "" + fileDate ) );
                         (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
          // tableModel.fireTableDataChanged();          
          // tableModel.fireTableRowsInserted(0,1);
          table.revalidate();
          table.validate();               
class MyTableModel extends DefaultTableModel
          int totalRows;
          int totalCols;
          public MyTableModel()
               super();
               setColumnIdentifiers (columnNames);
               this.totalRows = data.size();
               this.totalCols = columnNames.length;
          // this will return the row count of your table
          public int getRowCount()
               return totalRows;
          // this return the column count of your table
          public int getColumnCount()
               return totalCols;
          // this return the data for each cell in your table
          public Object getValueAt(int row, int col)
               MyObj obj = (MyObj)data.elementAt( row );
               if( obj != null )
                    if( col == 0 ) return( obj.first );
                    else if( col == 1 ) return( obj.last );
                    else if( col == 2 ) return( obj.third );
                    else if( col == 3 ) return( obj.fourth );
                    else return( "" );
               return "";
          // if you want your table to be editable then return true
          public boolean isCellEditable(int row, int col)
               return false;
          // if your table is editable edit the data vector here and
          // call table.tableChanged(...)
          public void setValueAt(Object value, int row, int col)
          protected void deleteSelections (int rows)
               try
                    removeRow(rows);
               catch(ArrayIndexOutOfBoundsException e)
                    System.out.println("The error in the row index " + rows);
               fireTableDataChanged() ;
class MyObj
          String first;
          String last;
          String third;
          String fourth;
          public MyObj( String f, String l, String t, String fo )
               this.first = f;
               this.last = l;
               this.third = t;
               this.fourth = fo;
#####################################

The following code works fine but it doesn't show me the new updated date in my JTable. I tried to print the values that I am getting and it does give the values on the prompt but doesn't show me on the JTable only first two are shown and the rest of the table is filled with the same values. I don't know what's going on and am tired of this TableModel thing so pla. take a time to give me some suggestions. Thanks
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class SimpleTable extends JPanel {
     /** Formats the date */
     protected SimpleDateFormat           formatter;
/** two-dimensional array to hold the information for each column */
protected Object                     data[][];
/** variable to hold the date and time in a raw form for the directory*/
protected long                          dateDirectory;
/** holds the readable form converted date for the directories*/
protected String                     dirDate;
/** holds the readable form converted date for the files*/
protected String                     fileDate;
/** variable to hold the date and time in a raw form for the file*/
protected long                          dateFile;
/** holds the length of the file in bytes */
protected long                         totalLen;
/** convert the length to the wrapper class */
protected Long                         longe;
/** Vector to hold the sub directories */
protected Vector                     subDir;
/** holds the name of the selected directory */
protected String                    dirNameHold;
/** converting vector to an Array and store the values in this */
protected File                     directoryArray[];
/** hashtable to store the key-value pair */
protected static Hashtable hashTable = new Hashtable();
/** refer to the TableModel that is the default*/
protected DefaultTableModel      model;
/** stores the path of the selected file */
protected static String               fullPath;
/** stores the currently selected file */
protected static File selectedFilename;
/** stores the extension of the selected file */
protected static String           extension;
protected Vector                     m = new Vector(0,1);
/** holds the names of the columns */
protected final String columnNames[] = {"Name", "Size", "Type", "Modified"};
public SimpleTable(File directoryArray[])
          this.setLayout(new BorderLayout());
          this.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
          (SimpleTable.hashTable).clear();
          data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
          formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
          for(int k = 0; k < directoryArray.length; k++)
               if(directoryArray[k].isDirectory())
                    data[k][0] = directoryArray[k].getName();
                    data[k][2] = "File Folder";
                    dateDirectory = directoryArray[k].lastModified();
                    dirDate = formatter.format(new java.util.Date(dateDirectory));
                    data[k][3] = dirDate;
                    (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    
               else if(directoryArray[k].isFile())
                    data[k][0] = directoryArray[k].getName();
                    totalLen = directoryArray[k].length();
                    longe = new Long(totalLen);
                    data[k][1] = longe + " Bytes";
                    dateFile = directoryArray[k].lastModified();
                    fileDate = formatter.format(new java.util.Date(dateFile));
                    data[k][3] = fileDate;
                    (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
model = new DefaultTableModel();
model.addTableModelListener( new TableModelListener(){
          public void tableChanged( javax.swing.event.TableModelEvent e )
               System.out.println("************ I am inside the table changed method ********" );
          final JTable table = new JTable(model);
          table.getTableHeader().setReorderingAllowed(false);
          table.setRowSelectionAllowed(false);
          table.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
          table.setShowHorizontalLines(false);
          table.setShowVerticalLines(false);
          table.addMouseListener(new MouseAdapter()
/* public void mousePressed(MouseEvent e)
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
/* if(e.getClickCount() >= 2 &&
(table.getSelectedColumn() == 0) &&
((table.getColumnName(0)).equals(columnNames[0])))
     //System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
     upDateTable(table);
public void mouseReleased(MouseEvent e)
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
/* if(e.getClickCount() >= 2 &&
(table.getSelectedColumn() == 0) &&
((table.getColumnName(0)).equals(columnNames[0]))) */
     //System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
     upDateTable(table);
          /** set the columns */
          for(int c = 0; c < columnNames.length; c++)
               model.addColumn(columnNames[c]);
          /** set the rows */
          for(int r = 0; r < data.length; r++)
               model.addRow(data[r]);
          DefaultTableCellRenderer D_headerRenderer = (DefaultTableCellRenderer ) table.getTableHeader().getDefaultRenderer();
          table.getColumnModel().getColumn(0).setHeaderRenderer(D_headerRenderer );
          ((DefaultTableCellRenderer)D_headerRenderer).setToolTipText("File and Folder in the Current Folder");
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
this.add(scrollPane, BorderLayout.CENTER);
* Returns the number of columns
public int getColumnTotal()
     return columnNames.length;
* Returns the number of rows
public int getRowTotal(Object directoryArray[])
     return directoryArray.length;
private void upDateTable(JTable table)
if((table.getSelectedColumn() == 0) && ((table.getColumnName(0)).equals(columnNames[0])))
     dirNameHold =(String) table.getValueAt(table.getSelectedRow(),table.getSelectedColumn());
               File argument = findPath(dirNameHold);
               if(argument.isFile())
                    CMRDialog.fileNameTextField.setText(argument.getName());
                    try
                         fullPath = argument.getCanonicalPath();                          
                         selectedFilename = argument.getCanonicalFile();                          
CMRDialog.filtersComboBox.removeAllItems();
                         extension = fullPath.substring(fullPath.lastIndexOf('.'));
                         CMRDialog.filtersComboBox.addItem("( " + extension + " )" + " File");
                    catch(IOException e)
                         System.out.println("THE ERROR IS " + e);
                    return;
               else if(argument.isDirectory())
                    String path = argument.getName();
                         //find the system dependent file separator
                         //String fileSeparator = System.getProperty("file.separator");
                    CMRDialog.driveComboBox.addItem(" " + path);
          subDir = Search.subDirs(argument);
          /**TBD:- needs a method to convert the vector to an array and return the array */
          directoryArray = new File[subDir.size()];
               int indexCount = 0;
               /** TBD:- This is inefficient way of converting a vector to an array */               
               Iterator e = subDir.iterator();               
               while( e.hasNext() )
                    directoryArray[indexCount] = (File)e.next();
                    indexCount++;
          /** now calls this method and clears the previous data */
          clearTableData(table);     
               (SimpleTable.hashTable).clear();
               data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
               formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
               m.clear();
               data = null;
               data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
               for(int k = 0; k < directoryArray.length; k++)
                    if(directoryArray[k].isDirectory())
                    System.out.println("Inside the if part");
                         data[k][0] = directoryArray[k].getName();
                         table.setValueAt(directoryArray[k].getName(),k,0);
                         //model.fireTableCellUpdated(k,0);
                         data[k][2] = "File Folder";
                         table.setValueAt("File Folder",k,2);
                         //model.fireTableCellUpdated(k,2);
                         dateDirectory = directoryArray[k].lastModified();
                         dirDate = formatter.format(new java.util.Date(dateDirectory));
                         data[k][3] = dirDate;
                         table.setValueAt(dirDate,k,3);
                         //model.fireTableCellUpdated(k,3);
                         (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
                         m.add(data);
                         model.addRow(m);
                         model.fireTableDataChanged();                              
                    else if(directoryArray[k].isFile())
               System.out.println("******* Inside the else part *******");
                         data[k][0] = directoryArray[k].getName();
               System.out.println("The Name is == " + data[k][0]);
                         table.setValueAt(directoryArray[k].getName(),k,0);
               System.out.println("The table cell value of the name is == " + table.getValueAt(k,0));
                         //model.fireTableCellUpdated(k,0);
                         totalLen = directoryArray[k].length();
                         longe = new Long(totalLen);
                         data[k][1] = longe + " Bytes";
               System.out.println("The length == " + data[k][1]);
                         table.setValueAt(longe + " Bytes",k,1);
               System.out.println("The table cell value of the length is == " + table.getValueAt(k,1));
                         //model.fireTableCellUpdated(k,0);
                         dateFile = directoryArray[k].lastModified();
                         fileDate = formatter.format(new java.util.Date(dateFile));
                         data[k][3] = fileDate;
               System.out.println("The modified date == " + data[k][3]);
                         table.setValueAt(fileDate,k,3);
               System.out.println("The table cell value of the name is == " + table.getValueAt(k,3));
                         //model.fireTableCellUpdated(k,0);
                         (SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);                    }
                         m.add(data);
                         model.addRow(m);
                         model.fireTableDataChanged();     
          // model.fireTableDataChanged();          
          // model.fireTableRowsInserted(0,1);
          table.revalidate();
          table.validate();               
     else
* Searches the Hashtable and returns the path of the folder or the value.
public File findPath(String value)
     return (File)((SimpleTable.hashTable).get(value));
* This clears the previous data in the JTable
public void clearTableData(JTable table)
     for(int row = 0; row < table.getRowCount() ; row++)
               for (int col = 0; col < table.getColumnCount() ; col++)
                    table.setValueAt(null, row , col);
          model.fireTableStructureChanged();
###

Similar Messages

  • Trains Stops and Insert new data using invokeAction!?

    Hi! I am using Train element to insert data in some tables. When I open first Train Step I use invokeAction to call CreateInsert operation and could insert new data in table1. Then I go to Train Step 2 and using invokeAction insert data in table2 and so on.
    I have two questions:
    1. When I go back to previous Train Step using "Back" button then invokeAction again calls CreateInsert operation, but I don't need it. It is possible to call CreateInsert operation using invokeAction ONLY if user goes forward by pressing "Next" button in Train element? If it is possible then What I need to change in my code?
    invokeAction source:
    <invokeAction Binds="CreateInsert" id="insert_mode"
                      RefreshCondition="${!requestContext.postback and empty bindings.exceptionsList}"
                      Refresh="prepareModel"/>2. It is possible to DISABLE some Train Stopas. For example, I want to disable first Train Stop for user when he go to next steps, so that user can't anymore go back to first Train Stop.
    Hope for Your answers, best regards, Debuger!

    Hi, Umesh! My use case is following: I am on first Train Stop and enter some data. Then I go to second Stop and enter some data and so on. When I go to first, second etc. Train stops I use invokeAcrion to call CreateInsert. I need to call only this operation when I press next button. When I press Back button I do not need to call Create Insert action. Hope You understand me.
    So, as I understand, i need to create method which indicates variable value based which button is pressed. But I don't understand how I can say, variable x=nextbuttonpressed or x=backbuttonpressed based on which button I realy press. And do not understand also how to use this variable in invokeAction Refresh Condition?
    Hope You can explain me that with steps to do in my case and can help with code?
    Waiting for response, best regards, Debuger.

  • BOM Change - Delete an item(s) and insert new line items

    Hi,
    We need to mass update BOMs like for some of the existing BOM's we need to delete some line items and insert new line items. We want to use the BOMMAT04 IDOC in LSMW but I'd like to know couple of things before I go ahead with that approach
    For instance, I've a finished good material 12345678 and it has three components
                          a) Item 0010 Material 30101010 of quantity 10
                          b) Item 0020 Material 30101011 of quantity 11
                          C) Item 0030 Material 30101012 of quantity 12
    Now, I'd like delete Item 0010 and add a new item 0040 Material 30101013 of quantity 13. 
    In the segment E1STKOM, there is LOEKZ (Deletion Flag) but I dont want to flag for deletion but instead delete the whole line item and add a new line item.
    Is there any way to achieve this using BOMMAT04 IDOC? If not, can you please suggest me a better way to do it
    Any help is greatly appreciated
    Thanks,
    Srinivas

    Dear Srinivas,
    1.IF you want to change for an individual BOM,use CS02,select the item which you want to delete,select the entire and click on
    delete button and then add new line items and save.
    2.For Mass changes of BOM you can use CS20.
    3.Check these functional module's also if you want to change using a report,
    CS_BI_BOM_CHANGE_BATCH_INPUT   Change bill of material via batch input    
    CSEP_MAT_BOM_SELECT_CHANGE     API Bills of Material: Select BOM(s)    
    CS_CL_P_BOM_MASS_CHANGE     
    CS_CL_S_BOM_CHANGE_COMPLETE 
    Check and revert back,.
    Regards
    Mangalraj.S

  • TS1702 i am not able to install update or remove itunes and install newer versions, windows installer service cannot be accessed,

    i am not able to install update or remove itunes and install newer versions,
    its stops installing and a windows error is shown
    i e ::   windows installer service could not be accessed , this could occur if you are running windows installer in safe mode
    or windows installer service is not correctly installed
    the same error happens if i try to uninstall the itunes from the control panel- remove programmes option
    im using windows 7 home basic 64 bit version
    this eroor is not happening with any other programmes..
    can someone tell me how to solve this issue
    thanx
    tushar

    Reinstalling iTunes is really daunting task. See
    http://www.apple.com/support/iphone/assistant/itunes/#section_6

  • Receiver JDBC: Error while doing the Deleting and Inserting new records

    Hi All,
              I am doing Idoc to JDBC scenario. In this I am collecting & bundling different type of Idocs and then sending to the JDBC receiver. My requirement is to delete the existing records in the database and insert the new records. I have configures as mentioned in the link
    Re: Combining DELETE and INSERT statements in JDBC receiver
    In the above link its shows for single mapping. In my scenario I am using multi mapping for collecting idocs in BPM. If I configured for normal mapping then it is working fine(Deleting existing records and Inserting new record). Whenever I am using multi mapping then I am getting following error in the receiver JDBC communication channel u201CError while parsing or executing XML-SQL document: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure)u201D . Can you please tell me what might be the problem.
    Thanks & Regards,
    T.Purushotham

    Hi !
    check this out:
    JDBC - No 'action' attribute found in XML document - error
    JDBC receiver adapter: No 'action' attribute found in XML document
    It appears that the inbound payload (the one that is going from XI to the JDBC adapter) does not have the requiered tag to specify which SQL action to execute in the receiver system. Maybe the multimapping is not creating the desired output message format.
    Regards,
    Matias.

  • I have changed provider and inserted new sim but it shows 'sim not valid' does anyone know how to unlock iPhone 5?

    i have changed provider and inserted new sim but it shows 'sim not valid' does anyone know how to unlock iPhone 5?

    Yes, contact the carrier the iPhone is locked to.
    Only they can officially unlock the iPhone and if you qualify. No one else.

  • Refresh jTable after inserting new data into the Database

    Hey all,
    I'm using Netbeans 6.5 to create a Desktop Application which is connected to a Java DB (Derby).
    The first simple steps were all very successfull:
    Create the jTable and bind it to the Database => everything works fine. When the application starts it correctly shows all data from the database.
    The problem starts when I try to insert new data to the database.
    For that reason I've created textfields and a button "Save". When I press the button it successfully inserts the data to the database but they are not displayed in the jTable (when the application starts they are all there, they are not updated at runtime) . I've tried table.invalidate() and table.repaint() but they just don't work.
    Any help will be GREATLY appreciated. But please have in mind that most of the code is Netbeans-generated and most of it not editable.
    Many thanks in advance.
    George

    Once again you are right my friend. I jumped to conclusion way too fast, when I shouldn't. (Give me a break, I've been busting my head with this well over a week). The response I saw when I did that was that indeed a line is added to the jTable. Because I falsly set the index of the object to be added to be second to last the row appeared on the table, what I didn't see at the time was that the last one disappeared. Hmm...
    A new adventure begins...
    So after a few hours of messing around with it here are my observations:
    1) It was not an observable list. When I add the new element with employeesList.add(newEmp); , the table gets notified but a get a bunch of exceptions:
    xception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 84, Size: 84
            at java.util.ArrayList.RangeCheck(ArrayList.java:546)
            at java.util.ArrayList.get(ArrayList.java:321)
            at org.jdesktop.swingbinding.impl.ListBindingManager$ColumnDescriptionManager.validateBinding(ListBindingManager.java:191)
            at org.jdesktop.swingbinding.impl.ListBindingManager.valueAt(ListBindingManager.java:99)
            at org.jdesktop.swingbinding.JTableBinding$BindingTableModel.getValueAt(JTableBinding.java:713)
            at javax.swing.JTable.getValueAt(JTable.java:1903)
            at javax.swing.JTable.prepareRenderer(JTable.java:3911)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
            at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
            at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
            at javax.swing.plaf.ComponentUI.update(ComponentUI.java:154)
            at javax.swing.JComponent.paintComponent(JComponent.java:743)
            at javax.swing.JComponent.paint(JComponent.java:1006)
            at javax.swing.JViewport.blitDoubleBuffered(JViewport.java:1602)
            at javax.swing.JViewport.windowBlitPaint(JViewport.java:1568)
            at javax.swing.JViewport.setViewPosition(JViewport.java:1098)
            at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.vsbStateChanged(BasicScrollPaneUI.java:818)
            at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:807)
            at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:348)
            at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:285)
            at javax.swing.DefaultBoundedRangeModel.setValue(DefaultBoundedRangeModel.java:151)
            at javax.swing.JScrollBar.setValue(JScrollBar.java:441)
            at javax.swing.plaf.basic.BasicScrollBarUI.scrollByUnits(BasicScrollBarUI.java:907)
            at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.mouseWheelMoved(BasicScrollPaneUI.java:778)
            at javax.swing.plaf.basic.BasicScrollPaneUI$MouseWheelHandler.mouseWheelMoved(BasicScrollPaneUI.java:449)
            at apple.laf.CUIAquaScrollPane$XYMouseWheelHandler.mouseWheelMoved(CUIAquaScrollPane.java:38)
            at java.awt.Component.processMouseWheelEvent(Component.java:5690)
            at java.awt.Component.processEvent(Component.java:5374)
            at java.awt.Container.processEvent(Container.java:2010)
            at java.awt.Component.dispatchEventImpl(Component.java:4068)
            at java.awt.Container.dispatchEventImpl(Container.java:2068)
            at java.awt.Component.dispatchMouseWheelToAncestor(Component.java:4211)
            at java.awt.Component.dispatchEventImpl(Component.java:3955)
            at java.awt.Container.dispatchEventImpl(Container.java:2068)
            at java.awt.Component.dispatchEvent(Component.java:3903)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
            at java.awt.Container.dispatchEventImpl(Container.java:2054)
            at java.awt.Window.dispatchEventImpl(Window.java:1801)
            at java.awt.Component.dispatchEvent(Component.java:3903)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 84, Size: 84
            at java.util.ArrayList.RangeCheck(ArrayList.java:546)
            at java.util.ArrayList.get(ArrayList.java:321)
            at org.jdesktop.swingbinding.impl.ListBindingManager$ColumnDescriptionManager.validateBinding(ListBindingManager.java:191)
            at org.jdesktop.swingbinding.impl.ListBindingManager.valueAt(ListBindingManager.java:99)
            at org.jdesktop.swingbinding.JTableBinding$BindingTableModel.getValueAt(JTableBinding.java:713)
            at javax.swing.JTable.getValueAt(JTable.java:1903)
            at javax.swing.JTable.prepareRenderer(JTable.java:3911)
            at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
    ... and a lot morewhich from my poor understanding means that the jTable succesfully notices the change but it is not able (??) to adjust to the new change. What is more interesting is that when I plainly add the element to the end of the list (without an idex that is), a blank row appears at the end of my Table. The weird thing is that I've bound the table to some text fields below it, and when I select that empty row all the data appear correctly to the text fields.
    I tried going through:
                    org.jdesktop.observablecollections.ObservableCollections.observableList(employeesList).add(newEmp);as well as
                    help = org.jdesktop.observablecollections.ObservableCollections.observableListHelper(employeesList);
                    help.getObservableList().add(newEmp);
                    help.fireElementChanged(employeesList.lastIndexOf(newEmp));and
                    obsemployeesList = org.jdesktop.observablecollections.ObservableCollections.observableList(employeesList);
                    obsemployeesList.add(newEmp);and I still get the same results (both the exeptions and the mysterious empty row at the end of the table
    So, I'm again in terrible need of your advice. I can't thank you enough for the effort you put into this.
    Best regards,
    George
    Edited by: tougeo on May 30, 2009 11:06 AM
    Edited by: tougeo on May 30, 2009 11:21 AM
    Edited by: tougeo on May 30, 2009 11:30 AM

  • When I insert new data on an existing graph, the graph deletes

    When I insert new data on an existing graph (for example, just adding a new year of data) and press insert, it just deletes the graph entirely. My only option is to recreate the entire graph which is frustrating because I lose its format and colors. Any suggestions?

    Here I opened the existing chart, with the old data. I need to remove the oldest year and add a new year. Which I do below:
    When I press the check mark, or enter, the graph details all delete.

  • How to improve performance(insert,delete and search) of table with large data.

    Hi,
    I am having a table which is used for maintaining history and have a large data and that keeps on increasing or decreasing based on the business rules.
    I am getting performance issues with this table which searching for any records or while inserting new data into it. I have already used index in this table but still I am facing lot of issues related to performance.
    Also, we used to insert bulk data into this table.
    Can we have any solution to achieve this, any solutions are greatly appreciated.
    Thanks in Advance!

    Please do not duplicate your posts across forums.  It's considered bad practice and rude, as people will not know what answers you've already received and may end up duplicating the effort.
    Locking this thread - answer on other thread please

  • Problem while inserting new Column in JTable

    Hi,
    I am facing Problem while inserting new Column in JTable.
    I have a JTable with one inherited ColumnModel class.
    When I am adding the column and moving towards the corresponding location, it moves successfully.
    but if I am adding another column or making any changes to table column structure the table retains the defualtcolumn structure.
    please help me to solve this..
    Regards
    Ranjith.........

    Maybe this example will help:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=579527

  • APP-PAY-06841: Person change exit between the old and the new date.

    Hi,
    Please help me by answering this question as very urgent basis.
    ABC employee Effective date should be of future dated 10-jan-2011.
    But ABC employee joining date has been entered on 10-Aug-2010.
    amd also this date is also ended by updating on 10-Dec-2010.
    But these records are wrong.This employee's effective date should be form 01-Jan-2011.
    how to datetrack.
    if iam changing the date bye keeping effective date as 10-Dec-2010 an an iam changing the record to 01-jan-2011,its throwing the error as "**APP-PAY-06841: Person change exit between the old and the new date**"
    Thanks&Regards,
    Sowmya.K

    What is the application release?
    Please see these docs.
    Error: APP-PAY-06841: Person changes exist between the old date and the new date [ID 399056.1]
    APP-PAY-06841 When Changing Latest Start Date Of An Employee Who Was An Ex-Contingent Worker [ID 1146414.1]
    Unable To Change Start Date for Employee, Get Error "APP-PAY-06841: Person Changes Exist Between The Old Date And The New Date" [ID 603233.1]
    Correcting Latest Start Date in People Screen Gives Error APP-PAY-06841 [ID 368289.1]
    How To Change the Latest Start Date of an Employee? [ID 329692.1]
    Thanks,
    Hussein

  • I m a new user plz give me icloud account bt previous owner she dead and i dont know about this information this phone. plz Help me icloud account as early as possible

    i m a new user plz give me icloud account bt previous owner she dead and i dont know about this information this phone. plz Help me icloud account as early as possible

    Apple is not here and will NOT give you the information. Contact the relatives of the "dead" owner.

  • Hey every one ,i bought a new ipad 2 last month,i am not using it  so much but  sometimes it does respond,hang's up,all games and app come out of there folder . can you plz help me

    hey every one ,i bought a new ipad 2 last month,i am not using it  so much but  sometimes it does respond,hang's up,all games and app come out of there folder . can you plz help me.my email id is [email protected]

    Try a reset. Hold the Sleep and Home button down for about 10 seconds until you see the Apple logo. Ignore the red slider.
    Don't leave your email address on a public forum

  • HT4623 i have apple iphone 4 32gb orange,currently i m india,and unable to use indian sim,and i have updated it to new ios6,can u plz help me out

    i have apple iphone 4 32gb orange,currently i m india,and unable to use indian sim,and i have updated it to new ios6,can u plz help me out

    Select the country in which the iPhone was originally sold:
    http://support.apple.com/kb/HT1937
    You'll find a link to the carrier on whose pages you can probably find contact information.
    As RG said, only the carrier to which the iPhone is locked can authorize unlocking. That is the only "way out". To have an iPhone that was "factory unlocked", you would have had to purchase it that way.
    Regards.

  • HT1414 my iphone 3g is not turn on after reboot only show me apple logo and then trun of auto . now its not get charging with my comp or adaptor. plz help me

    my iphone 3g is not turn on after reboot only show me apple logo and then trun of auto . now its not get charging with my comp or adaptor. plz help me

    I had the same problem i had to take to a shop to get a new battery so i did and now it is good so i suggest get a new battery hope this helped

  • I am having a lot of trouble downloading itunes.My latest error message is that MediaToolbox.dll is missing. I have been trying to fix this for three days now .And it all started with the last update .Can anyone help?

    I am having a lot of trouble downloading itunes.My latest error message is that MediaToolbox.dll is missing. I have been trying to fix this for three days now .And it all started with the last update .Can anyone help?

    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. If you're using Vista or 7, now head into your Uninstall a program control panel, select "Apple Application Support" and then click "Repair". If you're using XP, head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (If you've got XP, although the procedure is for Vista and 7, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever

Maybe you are looking for