CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Posts
    3

    insertColumn in a JTable?

    Hi,
    i need a Function for columns like DefaultTableModel.insertRow(). I think there is no. Does someone
    knows a workaround?

    By, Lars.


  2. #2
    Join Date
    Apr 1999
    Location
    Bangalore,India
    Posts
    43

    Re: insertColumn in a JTable?

    There is nothing like that in TableModel.
    But u can use the JTable's methods addColumn(TableColumn) and moveColumn(int,int);

    addColumn(TableColumn) will add a column at the end table. After that use moveColumn(int index, int target) to move your column where u want to be.

    I hope this will solve yours.

    regards,
    arun...


  3. #3
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: insertColumn in a JTable?

    Well there may be another way, if u have sub-classed 'AbstractTableModel'.

    U can make the sub-class work for dynamic columns. Here u just need to design the class such that,

    1. getColumnCount method returns the number of columns u want
    2. then other methods will reflect the change according to the number of columns.

    After u change the number of columns u just need to repaint the JTable.

    - UnicMan
    http://members.tripod.com/unicman

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured