DefaultModel addRow method

I made the following JTable with default model and used the default editors to show my comboBoxes as I want. the program is ok but when I clicked the addRow button, the new row is added but rendererd as object so, it
give me the String abbreviation of this object. those objects in the new row are edited as I want but they show me the string on the textfields and the combo boxes, I don't want it.
Please compile this program and give me the right solution
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractCellEditor;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author ep08363
public class JobsFollowUp extends JPanel{
    TableColumn tCol;
    JButton addButton;
    JButton removeButton;
    JComboBox engineerNames;
    JComboBox plantNames;
    JComboBox progressValue;
                             String[] columnNames = {"Engineer Name", "Job Description", "Plant", "Progress",
                                "Job No."};
         final Object[][] rowData = {{"Mohamad Samy", "", "Qar'a", "Finished", ""},
                              {"Ahmad El_Namoury", "", "A.M LPG", "In Progress", ""},
                              {"Ahmad Ismail", "", "Shipping", "Wait SD", ""},
                              {"Mohamad El_Gazar", "", "", "", ""},
                              {"Mohamad El_Askary", "", "", "", ""},};
    public JobsFollowUp(){
        //declare the buttons for adding and removing jobs
        addButton = new JButton("Add Job");
        removeButton = new JButton("Remove Job");
     //declare the table model
    final DefaultTableModel model = new DefaultTableModel(rowData, columnNames ){
        @Override
        public Class getColumnClass(int col){
            return (getValueAt(0,col).getClass());
    final JTable table = new JTable(model);
    table.setFillsViewportHeight(false);
    JScrollPane scrollPane = new JScrollPane(table);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(addButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(removeButton))
                    .addComponent(scrollPane, 0, 375, Short.MAX_VALUE))
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(removeButton)
                    .addComponent(addButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    TableColumn column = null;
    for(int i=0; i<5; i++){
      column = table.getColumnModel().getColumn(i);
        if(i==0)
            column.setPreferredWidth(80);
        else if(i==1)         
            column.setPreferredWidth(500);
        else if(i==2)         
            column.setPreferredWidth(30);       
        else if(i==3)         
            column.setPreferredWidth(30);
        else if(i==4)         
            column.setPreferredWidth(30);
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setCellSelectionEnabled(true);
    //set the color for the table header
    JTableHeader header = table.getTableHeader();
    //paint the rows as per the renderers class
    header.setBackground(Color.CYAN);
    header.setToolTipText("brain out, figure out");
    for(int i=0;i<5;i++){
    tCol = table.getColumnModel().getColumn(i);
    tCol.setCellRenderer(new CustomTableCellRenderer() );
    }//end of for statment
    CustomTableCellRenderer renderer = new CustomTableCellRenderer();
    renderer.setToolTipText("my first tool tip ever in java");
    table.getColumnModel().getColumn(1).setCellRenderer(renderer);
    //sorter test
    table.setAutoCreateRowSorter(true);
    //make the combo for the first column for engineer names
     engineerNames = new JComboBox();
    engineerNames.addItem("Mohamad Samy");
    engineerNames.addItem("Ahmad El_Namoury");
    engineerNames.addItem("Ahmad Ismail");
    engineerNames.addItem("Mohamad El_Gazar");
    engineerNames.addItem("Mohamad Tolba");
    engineerNames.addItem("Mohamad El_Askary");   
    final TableColumn engineerNamesColumn = table.getColumnModel().getColumn(0);
    engineerNamesColumn.setCellEditor(new DefaultCellEditor(engineerNames));
    //make the combo for the first column for plant Names
    plantNames = new JComboBox();
    plantNames.addItem("Qar'a");
    plantNames.addItem("A.M LPG");
    plantNames.addItem("Shipping");   
    TableColumn plantNamesColumn = table.getColumnModel().getColumn(2);
    plantNamesColumn.setCellEditor(new DefaultCellEditor(plantNames));
    //make the combo for the first column for job situation
    progressValue = new JComboBox();
    progressValue.addItem("Finished");
    progressValue.addItem("In Progress");
    progressValue.addItem("Wait for SD");   
    TableColumn progressColumn = table.getColumnModel().getColumn(3);
    progressColumn.setCellEditor(new DefaultCellEditor(progressValue));
        addButton.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource()==addButton){
                        model.addRow(rowData);
    }//end of constructor
   class CustomTableCellRenderer extends DefaultTableCellRenderer{
        @Override
        public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int col){
            Component cell = super.getTableCellRendererComponent(table, obj, isSelected, hasFocus, row, col);
                if(isSelected){
                    cell.setBackground(Color.WHITE);
                else{
                    if(row %2 ==0){
                        cell.setBackground(Color.white);
                    else{
                        cell.setBackground(Color.LIGHT_GRAY);
                    return cell;
        }//End of the Custom table cell renderer
    private static void createAndShowGUI(){
    JFrame frame = new JFrame("1st Table in Oracle Documents");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JobsFollowUp tablePanel = new JobsFollowUp();
    tablePanel.setOpaque(true);
    frame.setContentPane(tablePanel);
    frame.setSize(1000, 340);
    frame.setVisible(true);
}// end of create GUI
    public static void main(String[] args){
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            createAndShowGUI();
    });//end of main method
}

You're currently adding all data, i.e. the 2d array to one row again. Just add empty Stringsif(e.getSource()==addButton){
    model.addRow(new String[]{"", "", "", "", ""});
}

Similar Messages

  • Problem with addRow and MultiLine Cell renderer

    Hi ,
    Ive a problem with no solution to me .......
    Ive seen in the forum and Ivent found an answer.......
    The problem is this:
    Ive a JTable with a custom model and I use a custom multiline cell renderer.
    (becuse in the real application "way" hasnt static lenght)
    When I add the first row all seem to be ok.....
    when I try to add more row I obtain :
    java.lang.ArrayIndexOutOfBoundsException: 1
    at javax.swing.SizeSequence.insertEntries(SizeSequence.java:332)
    at javax.swing.JTable.tableRowsInserted(JTable.java:2926)
    at javax.swing.JTable.tableChanged(JTable.java:2858)
    at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableMo
    del.java:280)
    at javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTa
    bleModel.java:215)
    at TableDemo$MyTableModel.addRow(TableDemo.java:103)
    at TableDemo$2.actionPerformed(TableDemo.java:256)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
    64)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1817)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:419)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5134)
    at java.awt.Component.processEvent(Component.java:4931)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3639)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    at java.awt.Container.dispatchEventImpl(Container.java:1609)
    at java.awt.Window.dispatchEventImpl(Window.java:1590)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    This seems to be caused by
    table.setRowHeight(row,(getPreferredSize().height+2)); (line 164 of my example code)
    About the model I think its ok.....but who knows :-(......
    Please HELP me in anyway!!!
    Example code :
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableDemo extends JFrame {
    private boolean DEBUG = true;
    MyTableModel myModel = new MyTableModel();
    MyTable table = new MyTable(myModel);
    int i=0;
    public TableDemo() {
    super("TableDemo");
    JButton bottone = new JButton("Aggiungi 1 elemento");
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    getContentPane().add(bottone,BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    bottone.addActionListener(Add_Action);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    class MyTable extends JTable {
    MultiLineCellRenderer multiRenderer=new MultiLineCellRenderer();
    MyTable(TableModel tm)
    super(tm);
    public TableCellRenderer getCellRenderer(int row,int col) {
              if (col==1) return multiRenderer;
              else return super.getCellRenderer(row,col);
    class MyTableModel extends AbstractTableModel {
    Vector data=new Vector();
    final String[] columnNames = {"Name",
    "Way",
    "DeadLine (ms)"
    public int getColumnCount() { return 3; }
    public int getRowCount() { return data.size(); }
    public Object getValueAt(int row, int col) {
    Vector rowdata=(Vector)data.get(row);
                                                                return rowdata.get(col); }
    public String getColumnName(int col) {
    return columnNames[col];
    public void setValueAt (Object value, int row,int col)
         //setto i dati della modifica
    Vector actrow=(Vector)data.get(row);
    actrow.set(col,value);
         this.fireTableCellUpdated(row,col);
         public Class getColumnClass(int c)
              return this.getValueAt(0,c).getClass();
         public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col == 1)
    return false;
    else
    return true;
    public void addRow (String name,ArrayList path,Double dead) {
         Vector row =new Vector();
         row.add(name);
         row.add(path);
         row.add(dead);
         row.add(name); //!!!Mi tengo questo dato da utilizzare come key per andare a
         //prendere il path nella lista dei paths di Project
         //(needed as key to retrive data if name in col. 1 is changed)
         data.add(row);
         //Inspector.inspect(this);
         System.out.println ("Before firing Adding row...."+this.getRowCount());
         this.fireTableRowsInserted(this.getRowCount(),this.getRowCount());
    public void delRow (String namekey)
    for (int i=0;i<this.getRowCount();i++)
    if (namekey.equals(this.getValueAt(i,3)))
    data.remove(i);
    this.fireTableRowsDeleted(i,i);
    //per uscire dal ciclo
    i=this.getRowCount();
    public void delAllRows()
    int i;
    int bound =this.getRowCount();     
    for (i=0;i<bound;i++)     
         {data.remove(0);
         System.out.println ("Deleting .."+data);
    this.fireTableRowsDeleted(0,i);          
    class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
    private Hashtable rowHeights=new Hashtable();
    public MultiLineCellRenderer() {
    setEditable(false);
    setLineWrap(true);
    setWrapStyleWord(true);
    //this.setBorder(new Border(
    public Component getTableCellRendererComponent(JTable table,Object value,                              boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println ("Renderer called"+value.getClass());
    if (value instanceof ArrayList) {
    String way=new String     (value.toString());
    setText(way);
    TableColumn thiscol=table.getColumn("Way");
    //System.out.println ("thiscol :"+thiscol.getPreferredWidth());
    //setto il size della JTextarea sulle dimensioni della colonna
    //per quanto riguarda il widht e su quelle ottenute da screen per l'height
    this.setSize(thiscol.getPreferredWidth(),this.getPreferredSize().height);
    // set the table's row height, if necessary
    //System.out.println ("Valore getPreferred.height"+getPreferredSize().height);
         if (table.getRowHeight(row)!=(this.getPreferredSize().height+2))
         {System.out.println ("Setting Row :"+row);
             System.out.println ("Dimension"+(getPreferredSize().height+2));
             System.out.println ("There are "+table.getRowCount()+"rows in the table ");
             if (row<table.getRowCount())
             table.setRowHeight(row,(getPreferredSize().height+2));
    else
    setText("");
    return this;
    /**Custom JTextField Subclass che permette all'utente di immettere solo numeri
    class WholeNumberField extends JTextField {
    private Toolkit toolkit;
    private NumberFormat integerFormatter;
    public WholeNumberField(int value, int columns) {
    super(columns);
    toolkit = Toolkit.getDefaultToolkit();
    integerFormatter = NumberFormat.getNumberInstance(Locale.US);
    integerFormatter.setParseIntegerOnly(true);
    setValue(value);
    public int getValue() {
    int retVal = 0;
    try {
    retVal = integerFormatter.parse(getText()).intValue();
    } catch (ParseException e) {
    // This should never happen because insertString allows
    // only properly formatted data to get in the field.
    toolkit.beep();
    return retVal;
    public void setValue(int value) {
    setText(integerFormatter.format(value));
    protected Document createDefaultModel() {
    return new WholeNumberDocument();
    protected class WholeNumberDocument extends PlainDocument {
    public void insertString(int offs,
    String str,
    AttributeSet a)
    throws BadLocationException {
    char[] source = str.toCharArray();
    char[] result = new char[source.length];
    int j = 0;
    for (int i = 0; i < result.length; i++) {
    if (Character.isDigit(source))
    result[j++] = source[i];
    else {
    toolkit.beep();
    System.err.println("insertString: " + source[i]);
    super.insertString(offs, new String(result, 0, j), a);
    ActionListener Add_Action = new ActionListener() {
              public void actionPerformed (ActionEvent e)
              System.out.println ("Adding");
              ArrayList way =new ArrayList();
              way.add(new String("Uno"));
              way.add(new String("Due"));
              way.add(new String("Tre"));
              way.add(new String("Quattro"));
              myModel.addRow(new String("Nome"+i++),way,new Double(0));     
    public static void main(String[] args) {
    TableDemo frame = new TableDemo();
    frame.pack();
    frame.setVisible(true);

    In the addRow method, change the line
    this.fireTableRowsInserted(this.getRowCount(),this.getRowCount()); to
    this.fireTableRowsInserted(data.size() - 1, data.size() - 1);Sai Pullabhotla

  • Re-implementing DefaultTableModel.addRow()

    re-implemented addRow() to pass in type TableRow(class I implemented) which is similar to the the addRow() in the default implementation but doesn't require the calling class to know the column order of the data. So my table model just stores the TableRows in a Vector. I was working on the assumption that if I called fireTableChanged() in my addRow() method, that getValueAt() will get called to refresh the JTable. Thedoesn't work! Does anyone know what calls need to be made to get the table to refresh when a new row is added, or any docs that explains this?
    Thanks.

    this is how i do it. I've added this function to TableSorter.java from sun's demos. Hope this helps.
    public void addRow(JTable table, Object[] newRowData) {
    int cc = getColumnCount();
    int rc = getRowCount();
    Object[][] curr= new Object[rc+1][cc];
    for (int c=0; c < cc; c++){
              for (int r=0; r < rc; r++){
                   curr[r][c] = data[r][c];     
              try{
              curr[data.length][c] = newRowData[c];
         }catch(Exception e){
         curr[data.length][c] = "";
    this.setRowData(curr); //method I created in MyTableModel class
    this.reallocateIndexes(); //see below
    this.updateTable(); //see below
    table.repaint();
    public final void updateTable(){
         super.tableChanged(new TableModelEvent(this));
    public void reallocateIndexes() {
         int rowCount = getRowCount();
                   indexes = new int[rowCount];
                   for (int row = 0; row < rowCount; row++) {
         indexes[row] = row;
                   int colCount = getColumnCount();
                   colindexes = new int[colCount];
                   for (int col = 0; col < colCount; col++) {
         colindexes[col] = col;
         }

  • Error in JTable Row Header

    in my program i am displaying a row header in my JTable it is displaying no problem in these the real problem is that the row header extends to the end of the frame .. is that happen or i made any mistake
    here is my code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class RowHeaderExample1    extends JFrame
    JTable table;
    public RowHeaderExample1()
    super("Row Header Example1"); 
      setSize(300, 150);
        ListModel listModel = new AbstractListModel()
      String headers[] =
    "Row 1", "Row 2", "Row 3", "Row 4", "Row 5", "Row 6"}; 
        public int getSize()
    return headers.length;   
      public Object getElementAt(int index)
    {        return headers[index];  
    DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),        10); 
      table = new JTable(defaultModel);  
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 
      // Create single component to add to scrollpane 
      final JList rowHeader = new JList(listModel);  
    rowHeader.setFixedCellWidth(40);  
    rowHeader.setFixedCellHeight(table.getRowHeight());  
    rowHeader.setCellRenderer(new RowHeaderRenderer1(table)); 
      JScrollPane scroll = new JScrollPane(table); 
      scroll.setRowHeaderView(rowHeader);   
    // Adds row-list left of the table 
      getContentPane().add(scroll, BorderLayout.CENTER); 
      rowHeader.addMouseListener(new MouseAdapter()
      public void mouseClicked(MouseEvent e) {   
        System.out.println("click Here 1");   
        int index = rowHeader.locationToIndex(e.getPoint());  
         table.setRowSelectionInterval(index, index);   
        table.requestFocus();   
      public static void main(String[] args)
    RowHeaderExample1 frame = new RowHeaderExample1();   
    frame.addWindowListener(new WindowAdapter()
       public void windowClosing(WindowEvent e)
    {        System.exit(0);    
      frame.setVisible(true);
    class RowHeaderRenderer1 extends JButton implements ListCellRenderer{ 
      JTable table; 
      public RowHeaderRenderer1(JTable table)
    this.table = table; 
        setFont(new Font("Dialog",0,11));   
      setMargin(new Insets(0,0,0,0));  
    public Component getListCellRendererComponent(JList list, Object value,int index, boolean isSelected, boolean hasFocus)
    list.setBackground(getBackground());  
       this.setText(value.toString());   
      return this;   
    public Component getListCellRendererComponent(JList list, Object value, boolean isSelected, boolean hasFocus){   
    list.setBackground(getBackground());    
    this.setText(value.toString());   
      return this; 
    }}

    try this
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class RowHeaderExample2
        extends JFrame {
      JTable table;
      DefaultListModel lstModel;
      DefaultTableModel defaultModel;
      public RowHeaderExample2() {
        super("Row Header Example");
        setSize(300, 150);
        lstModel = new DefaultListModel();
        lstModel.addElement("Row 1");
        lstModel.addElement("Row 2");
        lstModel.addElement("Row 3");
        lstModel.addElement("Row 4");
        defaultModel = new DefaultTableModel(lstModel.getSize(), 6);
        table = new JTable(defaultModel);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        // Create single component to add to scrollpane
        final JList rowHeader = new JList(lstModel);
        rowHeader.setFixedCellWidth(40);
        rowHeader.setFixedCellHeight(table.getRowHeight());
        rowHeader.setCellRenderer(new RowHeaderRenderer2(table));
        JButton btnAdd = new JButton("Add");
        btnAdd.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
            lstModel.addElement("Row "+lstModel.getSize()+1);
            defaultModel.addRow(new Object[]{"","","","","",""});
        JPanel panel = new JPanel();
        panel.add(btnAdd);
        JScrollPane scroll = new JScrollPane(table);
        scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
        getContentPane().add(panel, BorderLayout.NORTH);
        getContentPane().add(scroll, BorderLayout.CENTER);
        rowHeader.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            System.out.println("click Here 1");
            int index = rowHeader.locationToIndex(e.getPoint());
            table.setRowSelectionInterval(index, index);
            table.requestFocus();
      public static void main(String[] args) {
        RowHeaderExample2 frame = new RowHeaderExample2();
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.setVisible(true);
    * Define the look/content for a cell in the row header
    * In this instance uses the JTables header properties
    class RowHeaderRenderer2
        extends JLabel
        implements ListCellRenderer {
       * Constructor creates all cells the same
       * To change look for individual cells put code in
       * getListCellRendererComponent method
      JTable table;
      RowHeaderRenderer2(JTable table) {
        this.table = table;
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
       * Returns the JLabel after setting the text of the cell
      public Component getListCellRendererComponent(JList list,
                                                    Object value, int index,
                                                    boolean isSelected,
                                                    boolean cellHasFocus) {
        list.setBackground(table.getTableHeader().getBackground());
        setText( (value == null) ? "" : value.toString());
        return this;
    }

  • JTable add a field JTextField

    hello
    I have a problem inserting into a table field JTextField
    I create my table in a window called Windows (class) following:
    Code:
    JScrollPane jScrollPane1 = new JScrollPane();
           String[] head = {"Nom", "Prènom", "Adresse", "Telephone", "ville ", "pays", "code Postal"};
           DefaultTableModel defaultModel = new DefaultTableModel(head, 0);
    JTable msgTable = new JTable(defaultModel);add to Class A:
    jScrollPane1.getViewport().add(msgTable);it works the table is displayed with the titles
    My first question is if I want to display in my table that the name and prémon
    What is the method?
    I create another class B intégtrant JTextField I wanted to write the fields (name, surname ,....) in JTextField with a button and add these fields to the table that is in Class A
    Following the code:
    JTextField name = new JTextField();
         JTextField addr = new JTextField();
    this.getContentPane().add(nameTField);
    this.getContentPane().add(addrTField);adding a button with an event insertion
    I tried addRow method and the other but I think the problem is the textField it must be changed into an object
    thank you for mounted a method to solve my problem

    addRow should work. But from the code you posted, we cannot see why it does not.
    Prepare an SSCCE and we can assist you. - And maybe, when writing the SSCCE, you discover the error yourself.

  • JTable checkboxes doesn't retain their selection when a new row is added!!

    HI,
    My gui has the JTable component which has 5 columns. out of which 4 columns are checkboxes. whenever i select an item from the Jlist and click on the add button it will add a new row in JTable.
    but the problem is whenever a new row is added to the table. the previously selected checkboxes of previous rows are being deselected. But i want to retain the selection of my previous rows even when a new row is added. please help me how to achieve this..i am posting my JTable code here:
    class FunctionTableModel extends AbstractTableModel{
           /** The instances who's attribute structure we are reporting */
        //protected InitModel m_init;
        protected String func_element;
        protected int counter;
        //protected String[] func_array;
        protected Vector func_vector;
        /** The flag for whether the instance will be included */
        protected boolean [] m_Sum;
        protected boolean [] m_Min;
        protected boolean [] m_Avg;
        protected boolean [] m_Max;
        protected boolean [] m_SD;
         * Creates the tablemodel with the given set of instances.
         * @param instances the initial set of Instances
        public FunctionTableModel() {
          counter =0;
             func_vector = new Vector();
         public FunctionTableModel(Vector vec) {
            func_vector = vec;
        public Vector getDataVector(){
            return func_vector;
         * Sets the tablemodel to look at a new set of instances.
         * @param instances the new set of Instances.
        public void setElement(Vector vec) {
               for(int i=0;i<vec.size();i++){
            func_vector.add(vec.elementAt(i));
            counter++;
          fireTableDataChanged();   
          m_Sum = new boolean [counter];
          m_Min = new boolean[counter];
          m_Avg = new boolean[counter];
          m_Max = new boolean[counter];
          m_SD = new boolean[counter];
         * Gets the number of attributes.
         * @return the number of attributes.
        public int getRowCount() {
               return func_vector.size();
         * Gets the number of columns: 3
         * @return 3
        public int getColumnCount() {
          return 6;
         * Gets a table cell
         * @param row the row index
         * @param column the column index
         * @return the value at row, column
        public Object getValueAt(int row, int column) {
          switch (column) {
          case 0:
            return func_vector.elementAt(row);
          case 1:
            return new Boolean(m_Sum[row]);
          case 2:
            return new Boolean(m_Min[row]);
          case 3:
            return new Boolean(m_Avg[row]);
          case 4:
            return new Boolean(m_Max[row]);
          case 5:
            return new Boolean(m_SD[row]); 
          default:
            return null;
        public void removeAll(){
            func_vector.removeAllElements();
            fireTableDataChanged();
         * Gets the name for a column.
         * @param column the column index.
         * @return the name of the column.
        public String getColumnName(int column) {
          switch (column) {
          case 0:
            return new String("Function Selected");
          case 1:
            return new String("Sum");
          case 2:
            return new String("Min");
          case 3:
            return new String("Avg");
          case 4:
            return new String("Max");
          case 5:
            return new String("SD");   
          default:
         return null;
         * Sets the value at a cell.
         * @param value the new value.
         * @param row the row index.
         * @param col the column index.
        public void setValueAt(Object value, int row, int col) {
          if(col == 0){
            counter++;
            func_vector.add(counter,value.toString());
          if (col == 1)
            m_Sum[row] = ((Boolean) value).booleanValue();
          if (col == 2)
            m_Min[row] = ((Boolean) value).booleanValue();
          if (col == 3)
            m_Avg[row] = ((Boolean) value).booleanValue();
          if (col == 4)
            m_Max[row] = ((Boolean) value).booleanValue();
          if (col == 5)
            m_SD[row] = ((Boolean) value).booleanValue();       
         * Gets the class of elements in a column.
         * @param col the column index.
         * @return the class of elements in the column.
        public Class getColumnClass(int col) {
             return getValueAt(0, col).getClass();
         * Returns true if the column is the "selected" column.
         * @param row ignored
         * @param col the column index.
         * @return true if col == 1.
        public boolean isCellEditable(int row, int col) {
          if (col >= 1) {
             return true;
          return false;
        public void removeRow(int row){
            if(row<=func_vector.size()){
                          func_vector.removeElementAt(row);
                counter--;
            fireTableDataChanged();
        }

    hi parvathi,
    i have made changes to my previous code and here's the code:
      class FunctionTableModel extends DefaultTableModel{
           /** The instances who's attribute structure we are reporting */
        //protected InitModel m_init;
        protected String func_element;
        protected int counter;
        protected int counter1;
        //protected String[] func_array;
        protected Vector func_vector;
        /** The flag for whether the instance will be included */
        protected boolean [] m_Sum;
        protected boolean [] m_Min;
        protected boolean [] m_Avg;
        protected boolean [] m_Max;
        protected boolean [] m_SD;
        //protected Vector m_Sum1;
        //protected Vector m_Min1;
        //protected Vector m_Avg1;
        //protected Vector m_Max1;
        //protected Vector m_SD1;
         * Creates the tablemodel with the given set of instances.
         * @param instances the initial set of Instances
        public FunctionTableModel() {
            System.out.println("entered the constr");
          counter =0;
          //counter1=0;
          //m_Sum1 = new Vector();
          //m_Min1 = new Vector();
          //m_Avg1 = new Vector();
          //m_Max1 = new Vector();
          //m_SD1 = new Vector();
          //func_array = new String[];
          func_vector = new Vector();
         public FunctionTableModel(Vector vec) {
            func_vector = vec;
            //setElement(func_vector);
        public Vector getDataVector(){
            return func_vector;
         * Sets the tablemodel to look at a new set of instances.
         * @param instances the new set of Instances.
        public void addRow(Vector vec) {
          //counter++; 
          //func_element = ele;
          //System.out.println("FunctionTableModel- setElement() method");
          for(int i=0;i<vec.size();i++){
            func_vector.add(vec.elementAt(i));
            counter++;  
           //System.out.println("counter ="+counter+new boolean[counter]); 
            //m_Sum1 = m_Sum;
            //m_Min1 = m_Min;
            //m_Avg1 = m_Avg;
            //m_Max1 = m_Max;
            //m_SD1 = m_SD;
            //m_Sum = new boolean[counter];
            //System.out.println("at setElement");
            m_Sum = new boolean[counter];
            //System.out.println(counter);
            m_Min = new boolean[counter];
            //m_Min;
            m_Avg = new boolean[counter];
            //m_Avg1 = m_Avg;
            m_Max = new boolean[counter];
            //m_Max1 = m_Max;
            m_SD = new boolean[counter];
            //m_SD1 = m_SD;
            //counter1++;
          //func_array[counter]=ele;
          //func_vector.add(counter,ele);
          fireTableDataChanged();  
         * Gets the number of attributes.
         * @return the number of attributes.
        //public int getRowCount() {
          //System.out.println("FunctionTableModel- getRowCount() method");
          //return func_vector.size();
         * Gets the number of columns: 3
         * @return 3
        public int getColumnCount() {
          return 6;
         * Gets a table cell
         * @param row the row index
         * @param column the column index
         * @return the value at row, column
        public Object getValueAt(int row, int column) {
          switch (column) {
          case 0:
            return func_vector.elementAt(row);
          case 1:{
            //System.out.println("in case 1");
            //Boolean m_Sum_Value = new Boolean(m_Sum[row]);
            //System.out.println("m_Sum_Value:"+m_Sum_Value.booleanValue());
            return new Boolean(m_Sum[row]);
            //m_Sum1.add(m_Sum_Value);
            //return m_Sum_Value;
          case 2:
            return new Boolean(m_Min[row]);
          case 3:
            return new Boolean(m_Avg[row]);
          case 4:
            return new Boolean(m_Max[row]);
          case 5:
            return new Boolean(m_SD[row]); 
          default:
            return null;
        public void removeAll(){
            func_vector.removeAllElements();
            //m_Sum1.removeAllElements();
            fireTableDataChanged();
         * Gets the name for a column.
         * @param column the column index.
         * @return the name of the column.
        public String getColumnName(int column) {
          switch (column) {
          case 0:
            return new String("Function Selected");
          case 1:
            return new String("Sum");
          case 2:
            return new String("Min");
          case 3:
            return new String("Avg");
          case 4:
            return new String("Max");
          case 5:
            return new String("SD");   
          default:
         return null;
         * Sets the value at a cell.
         * @param value the new value.
         * @param row the row index.
         * @param col the column index.
        public void setValueAt(Object value, int row, int col) {
          if(col == 0){
            counter++;
            func_vector.add(counter,value.toString());
          if (col == 1) {
            m_Sum[row] = ((Boolean) value).booleanValue();
            //System.out.println("m_Sum length "+m_Sum.length);
            //for(int i=0;i<=row;i++)
            //    System.out.println("m_Sum1 "+i+((Boolean)m_Sum1.elementAt(i)).booleanValue());
            //System.out.println("m_Sum1["+row+"] "+ ((Boolean)m_Sum1.elementAt(row)).booleanValue());
            //    System.out.println("m_Sum["+i+"] "+ m_Sum);
    if (col == 2)
    m_Min[row] = ((Boolean) value).booleanValue();
    if (col == 3)
    m_Avg[row] = ((Boolean) value).booleanValue();
    if (col == 4)
    m_Max[row] = ((Boolean) value).booleanValue();
    if (col == 5)
    m_SD[row] = ((Boolean) value).booleanValue();
    * Gets the class of elements in a column.
    * @param col the column index.
    * @return the class of elements in the column.
    public Class getColumnClass(int col) {
    return getValueAt(0, col).getClass();
    * Returns true if the column is the "selected" column.
    * @param row ignored
    * @param col the column index.
    * @return true if col == 1.
    public boolean isCellEditable(int row, int col) {
    if (col >= 1) {
         return true;
    return false;
    public void removeRow(int row){
    if(row<=func_vector.size()){
    func_vector.removeElementAt(row);
    counter--;
    fireTableDataChanged();
    previouslu i was using the setElement method. now i have replaced with the addRow method...
    but anyways...the control is not going to any of these overridden methods...and none of the elements are added to the table. But i comment of all the addRow, getValueAt, getColumnClass methods...then it's adding rows to the table but with only the first column all the remaiing columns are just empty...
    i am fed up with this...if you observe i have commented out somany lines...becoz i am trying to save my boolean array values into a vector..but that was also in vain...
    i appreciate for ur help...
    thanks
    sri

  • How to Add and delete a row while using Abstract Table Model

    Hi,
    I need to do the following functionalities in JTable.I've done tht but a small problem.
    1. Adding a row (Using addRow() method from DefaultTableModel).
    2. Deleting a row(Using setRowCount() method from Default Table Model).
    3. Sorting the table based on the selection of column(Using TableSorter which is using AbstracTableModel).
    As the sorting is mandatory i've to change my model to Abtract Table Model
    The problem is this Abstract Table Model doesn't have any methods to Add a row or deleting a row (setRowCount()).If anybody has written any utility method for this using Abstract Table Model help me.

    Using TableSorter which is using AbstracTableModel).If your talking about the TableSorter class from the Swing tutorial, then you create the TableSorter class by passing it a TableModel. There is no reason you can't use the DefaltTableModel.
    I changed the code in TableSorterDemo as follows:
            String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            Object[][] data = {
                {"Mary", "Campione",
                 "Snowboarding", new BigDecimal(1), new Boolean(false)},
                {"Alison", "Huml",
                 "Rowing", new BigDecimal(3), new Boolean(true)},
                {"Kathy", "Walrath",
                 "Knitting", new BigDecimal(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                 "Speed reading", new BigDecimal(20), new Boolean(true)},
                {"Philip", "Milne",
                 "Pool", new BigDecimal(10), new Boolean(false)}
              DefaultTableModel model = new DefaultTableModel(data, columnNames)
                   public Class getColumnClass(int c)
                        return getValueAt(0, c).getClass();
            TableSorter sorter = new TableSorter(model);
    //        TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS

  • Copying custom and system documents via SDK

    Hi everyone,
    A client needs to copy Purchase Order document to AR Invoice.
    Looks like that the only way to implement this feature is to straightly set matrix cells' values, for example
    var itemCode0 = InvoiceFormMatrix.Columns.Item("0").Cells.Item("0").Specific as EditText;
    itemCode0.Value = "Code00";
    So, the first question - is it any faster way to fill system matrixes? I've already tryed DBDataSource.SetValue() and Matrix.SetCellWithoutValidation() - they are forbidden to change system columns.
    The second question: matrix.AddRow() method doesn't increment the "#" column (Line Number) automatically, even after form.Update() call. How can I fix this issue?

    Hi Ankit,
    Yestarday I implemeted a similar approach. However, this sollution has several shortcomings:
    Extremely slow behaviour - it is obvious, however
    As I mentioned earlier - "#" column is filled with "1"-s - no automatic incrementation.
    I cannot set Description column, because it raises "ChooseFromList" if several ItemCodes has the same Description. First I set ItemCode, however, SDK doesn't set the corresponding Description automatically as one might expect. Suppressing ChooseFromList event "before action" (BubbleEvent = false) leads to emty Description column.
    Thus, I have a bunch of problems against a few benefits ...
    Hi Ady,
    "Why don't you use DI API to copy the SO to Draft AP Invoice" - this is the client demand. He needs such "Copy From" feature according to his business process. Also he opposes to any auxillary documents which could easily confuse inexperienced user of SAP B1.
    Best regards, Evgeny.

  • Itemrenderer in datagrid

    i've the following datagrid code:
    <mx:DataGrid  id="empdg"
      dataProvider="{employeeService.lastResult.employees.employee}"
      width="40%" editable="true"
    itemClick="addRow(event)">
    <mx:columns>
    <mx:DataGridColumn headerText="Reportees" editable="false" itemRenderer="components.empname" width="40"/>
    </mx:columns>
    </mx:DataGrid>
    the components.empname code is follows:
    <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    autoDrawBackground="true">
    <mx:HBox>
    <mx:Image source="http://abc.com/add.png"/>
    </mx:HBox>
    </s:MXDataGridItemRenderer>
    addrow method (in the datagrid) adds a new row when clicked on the column. i would like to change the image source in the above code dynamically to point to "delete.png" with the first column in the first row still pointing to add.png but first column in the second row pointing to delete.png (and so on). As of now when ever new row gets added, it comes with add.png in the first column of the new row...i want to replace this with delete.png.
    something like this:
    +
    Can somebody help?
    Thank you
    Bo

    Hello RootSounds,
    Good to hear from you again. Well yes, your understanding is correct.
    How do i do that?
    Bo

  • Table with add and remove row function

    i want to have table that function like exactly like email table in yahoo or hotmail or any. the last column will have the checkbox an there is a button that reside on the top of the table that is used to delete all the checked data. i have tried to use AbstractTableModel with the data of type object[] but i don't know how to make the addRow and removeRow. can anyone help me i'm stuck!
    [Delete all check data] <-- jButton
    names | contact no | email | delete |
    john | 0000000000 | [email protected] | [] <-- checkbox
    tom | 0000000000 | [email protected] | [] <-- checkbox

    Is this really difficult ???
    Just use DefaultTableModel, use addRow method for add row, and use removeRow method to remove a row.
    Just loop your all table rows, get value at first column like:
    for( int i = 0; i < tableModel.getRowCount(); i++ ){
        //i assume you have checkbox in first columun of your table
        Boolean isSelected = ( Boolean )tableModel.getValueAt( i, 0 );
        if( isSelected.booleanValue() ){
            tableModel.removeRow( i );
    }

  • Can't add row using table sorter

    I had a jtable with my own mytableModel that implements AbstractTableModel. In mytableModel, I have addRow, removeRow... so I can delete/add row dynamically by calling mytableModel.addRow(..). Everything works fine.
    However, after I added the table sorter and table map (got the code from the tutorial).
    MyTableModel myModel = new MyTableModel();
    TableSorter sorter = new TableSorter(myModel);
    JTable table = new JTable(sorter);
    sorter.addMouseListenerToHeaderInTable(table);
    Now, when i call mytableModel.addRow(..), it doesn't work anymore. It doesn't add a row anymore, why?
    Thank you so much for your help.

    I don't have a addRow method in TableSorter. My addRow method is in myTableModel. So, when I need to addRow, I called myTableModel.addRow, In my addRow method, I have fireTableRowsInserted method. This used to work using integrating with TableSorter.
    Do I need to move all my addRow, addCol....DelRow... to TableSorter? The table data are stored in myTableModel. I guess I really doesn't know how the TableSorter work :(
    Thanks

  • Adding a blank row to a JTable when a user begins to edit a current row

    Hi, this may be a daft question, but I've been looking through the forum and didnt find anything that really helped me. So I'm posting this in the hope someone will be a ble to point me in the right direction.
    In my current application I have a JTable. It currently contains a single emptry row. What I wish to happen is when a user begins to edit that empty row a new blank row is added to the bottom of the table.
    I'm using a custom table model, as there maybe data loaded from a Oracle database at a later date and have included an "addRow()" method which will add the blank row.
    What i'm struggling with is a way to detect when the user has started to edit the blank row and so when to call my "addRow()" method.
    I tried experimenting with propertyChange listeners but they didnt seem effective. Could someone please provide me with either a solution or a pointer in the right direction.
    Thanks for your help

    What I wish to happen is when a user begins to edit that empty row a new blank row is added to the bottom of the table.Well a user could start to edit the last row, but then they could use the escape key to cancel the cell editing. So I would only add the empty row once a cell has actually been updated.
    For this I would use a TableModelListener. The listener will only fire when the data in a cell is changed. So once the event is received you simply check if the row of the edited cell is the last row of the table.

  • Insert empty row

    Hi all,
    I am trying to insert a new emty row to my JTable. After the new row is inserted the user should fill in the values.
    I tried inserting dummy data; it works fine. However, when I try to insert an empty Vector I get the following exception. Any reasons for this?
    //code
    //static MyTableModel myModel = new static MyTableModel(columnNames, data);
    TableDemo.myModel.addRow( new Vector() );
    java.lang.ArrayIndexOutOfBoundsException: 4 > 0
         at java.util.Vector.insertElementAt(Vector.java:558)
         at javax.swing.table.DefaultTableModel.insertRow(DefaultTableModel.java:347)
         at javax.swing.table.DefaultTableModel.addRow(DefaultTableModel.java:323)
         at project.ListenerCreateRecordButton.actionPerformed(ListenerCreateRecordButton.java:24)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1834)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2152)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)

    Use the DefaultTableModel as is. I don't see any reason for you to extend it.
    This posting shows how to use the addRow method of the DefaultTableModel:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=577919

  • Unable to Load CSV file with comma inside the column(Sql Server 2008)

    Hi,
    I am not able load an CSV file with Comma inside a column. 
    Here is sample File:(First row contain the column names)
    _id,qp,c
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    "1","[ ""0"", ""0"", ""0"" ]","helloworld"
    When i specify the Text Qualifier as "(Double quotes) it work in SQL Server 2012, where as fail in the SQL Server 2008, complaining with error:
    TITLE: Microsoft Visual Studio
    The preview sample contains embedded text qualifiers ("). The flat file parser does not support embedding text qualifiers in data. Parsing columns that contain data with text qualifiers will fail at run time.
    BUTTONS:
    OK
    I need to do this in sql server 2008 R2 with Service pack 2, my build version is 10.50.1600.1.
    Can someone let me know it is possible in do the same way it is handle in SQL Server 2012?
    Or
    It got resolved in any successive Cumulative update after 10.50.1600.1?
    Regards Harsh

    Hello,
    If you have CSV with double quotes inside double quotes and with SSIS 2008, I suggest:
    in your data flow you use a script transformation component as Source, then define the ouput columns id signed int, Gp unicode string and C unicode string. e.g. Ouput 0 output colmuns
    Id - four-byte signed
    gp - unicode string
    cc - unicode string
    Do not use a flat file connection, but use a user variable in which you store the name of the flat file (this could be inside a for each file loop).
    The user variable is supplied as a a readonly variable argument to the script component in your dataflow.
    In the script component inMain.CreateNewOutputRows use a System.IO.Streamreader with the user variable name to read the file and use the outputbuffer addrow method to add each line to the output of the script component.
    Between the ReadLine instraction and the addrow instruction you have to add your code to extract the 3 column values.
    public override void CreateNewOutputRows()
    Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
    For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
    string line;
    System.IO.StreamReader file = new System.IO.StreamReader( Variables.CsvFilename);
    while ((line = file.ReadLine()) != null)
    System.Windows.Forms.MessageBox.Show(line);
    if (line.StartsWith("_id,qp,c") != true) //skip header line
    Output0Buffer.AddRow();
    string[] mydata = Yourlineconversionher(line);
    Output0Buffer.Id = Convert.ToInt32(mydata[0]);
    Output0Buffer.gp = mydata[1];
    Output0Buffer.cc = mydata[2];
    file.Close();
    Jan D'Hondt - SQL server BI development

  • Sequence execution all containing similar dataflows to database results in 1 sequence getting errors, all have TransactionOption=Supported

    I have 3 sequence Containers, all with TransactionOption = Supported. Each individual Sequence container contains a dataflow task that executes a script component to get data and write to output fields in table using OLE DB table Destination.
    All three Script Component sets up the data for the tables and has a preexecute, here is part of code in script component
       private System.String[] Transmissions;
        /// <summary>
        /// This method is called once, before rows begin to be processed in the data flow.
        /// You can remove this method if you don't need to do anything here.
        /// </summary>
        public override void PreExecute()
            base.PreExecute();
             * Add your code here
            this.Transmissions = this.ReadOnlyVariables["User::TransmissionData"].Value as System.String[];
        public override void CreateNewOutputRows()
              Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
              For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
            foreach (System.String Row in Transmissions)
                try
                    System.Array ar = Row.Split(",".ToCharArray());
                    //System.Int32.Parse(ar.GetValue(0).ToString());
                    //System.DateTime.Parse(ar.GetValue(1).ToString());
                    //System.Decimal.Parse(ar.GetValue(2).ToString());
                    System.DateTime.Parse(ar.GetValue(0).ToString());
                    System.DateTime.Parse(ar.GetValue(1).ToString());
                    System.Int32.Parse(ar.GetValue(3).ToString());
                    float.Parse(ar.GetValue(6).ToString());
                    OutputBuffer.AddRow();
                    OutputBuffer.StartDatetime = System.DateTime.Parse(ar.GetValue(0).ToString());
                    OutputBuffer.EndDateTime = System.DateTime.Parse(ar.GetValue(1).ToString());
    When I just execute the first two sequence containers, everything works, data written to tables.
    When I include the third sequence container, it throw an error like
    Script Component has encountered an exception in user code:
    Project name:  SC_2c..........................
    Object reference not set to an instance of object.
    at ScriptMain.PreExecute()
    at
    Microsoft.SqlSever.Dts.Piperline.ScriptComponentHost.PreExecute()
    Any ideas why when I include the third sequence/Script Component it fails? It looks like it failing in PreExecute
    thanks in advance.
    Greg Hanson

    HI Arthur thanks for answer, yes i believe it is a timing issue because when I run each container individually it works. I need to keep each sequence container separate, I believe, since a Script task (in C#) that parses the text file feeds each container
    separately. Each Sequence Container has "Transaction Supported" set. If I include 1 & 3, 2 & 3 it FAILS.
    This  is rough schematic of what I have. I thought of connecting the sequence containers, but that won't work as my Script Task that parses the file feeds separate into each sequence container:
    Script Task - Parses file into 3 separate DTS variables all containing array of strings:
    Transmission array of strings
    Energy array of strings
    Tag array of strings
    Script Task feeds into 3 separate Containers:
    Transmission container containing dataflow task that has Script Component that converts array to rows that uses oledb dest to load data into  transmission table
    Energy container containing separate dataflow task  that has Script Component  that converts array to rows that uses oledb dest to load data into Energy table
    Tag container containing separate dataflow task  that has Script Component that converts array to rows that uses oledb dest to load data into Tag table **** THIS FAILS
    I have also just tried using 1 sequence container for all Data Flow tasks, and it still fails on the last Load to Tag table data flow getting
    Script component has encountered an exception in user code:
    Project name:   SC_...
    Object reference not set to an instance of object.
    at ScriptMain.PreExecute()
    at
    Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
    YET WHEN I EXECUTE THIS CONTAINER SEPARATE IT WORKS.
    When I set a breakpoint in preexecute in LoadDatainto Tag Table Script Component and hit break, it WORKS!
    Please help this is due tomorrow! 
    Greg Hanson

Maybe you are looking for

  • Need info on how to load aspx files

    I created a "Contact Us" aspx page in Visual Web Developer 2008.  It is included in my defined site and root folder in Dreamweaver.  When I try to call the page, it opens a dialog box which asks if I want to Save or Open (or Cancel) the aspx page.  I

  • Idoc - file (n:1) .

    Hi experts, We have multiple idocs from sender side R/3 system for INVOICE. for example, we have 3 idocs from R/3 side, we received that at XI, now we need to send One XML file for Receiver side (output file) at ftp server for these 3 idocs. For all

  • Problem using File or URL ....

    i completly formatted my computer , before i did the format for instance whenever i instantiate a File f = new File("testInput.txt");that worked and i could do ouputstream or what ever but now i have to put the complete path .e.g File f = new File("c

  • Another iWeb question

    With my 06 updated to 08, I plan at the end of the year to not publish one of my websites. (I have two) I would like to save the one I am not publishing for use at another time. I will keep the other one up and running. How can I save the not publish

  • ERROR while generating Paid leave quota ( PT60)

    Hello Guys, I need some help ... while running TCODE PT60, am getting the following errors for some employees ... I am unable to identify the solution ... please help Caution: Start of processing set from 20090401 to 20090516    No entry in table T00