How to reinsert deleted columns in a Jtable
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to reinsert deleted columns in a Jtable

  1. #1
    Join Date
    Feb 2017
    Location
    Montreal
    Posts
    52

    How to reinsert deleted columns in a Jtable

    The code I am using states index out of bounds
    The code I am using is
    Code:
     void Insert(int index)
    {table.moveColumn(table.getColumnCount()-1,index);}
    Help

  2. #2
    Join Date
    Aug 2017
    Posts
    36

    Re: How to reinsert deleted columns in a Jtable

    The DefaultTableModel supports a setColumnCount() method which effectively will allow you to remove columns from the end of the model only.

    If you want to remove columns from the middle of the model, then you will need to:

    1. extend the DefaultTableModel and create your own removeColumn(int column) method.
    2. This method would need to loop through every row in the Vector and use the Vector.remove(int) method to remove the column for ever row.
    3. Finally once this is done you would need to invoke the fireTableStructureChanged() method to tell the table that a column has been removed so the table can be repainted.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)