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

    JTable Constructor problems w/ ColumnModels

    I think I may be missing something, and am hoping for help. I've tried this with both swing 1.1 and swing 1.1.1beta, and both have the same issue.

    I've created a Table Model

    public class TableAdapt extends AbstractTableModel
    { .... }

    which I then use in my main program:

    TableAdapt ta = new TableAdapt();
    final JTable table = new JTable(ta);

    This all works fine.

    I've tried creating an extension of DefaultTableColumnModel and then using it in the JTable constructor:
    final JTable table = new JTable(ta, myTableColumnModel);

    This breaks. Everything runs, but none of the cell information is drawn, including column headers. No division lines -- just white space.

    I checked the code of JTable. The constructors show that if parm 2 (tablecolumnmodel) is null, then it creates its own: new DefaultTableColumnModel();

    I figured my table model might be at fault, so I tried this:
    final JTable table = new JTable(ta, new DefaultTableColumnModel());

    This breaks it in exactly the same way. I've even tried creating an actual instance of the DefaultTableColumnModel before using it in the JTable constructor.

    Am I missing some behavior information somewhere? Is this a break/bug? I'd be happy to post code if needed, but anyone who's dealt with at least constructing from AbstractTableModel should be able to reproduce this.


  2. #2
    Join Date
    Apr 1999
    Location
    Canada
    Posts
    12

    Re: JTable Constructor problems w/ ColumnModels

    If you do not call addColumn in your DefaultTableColumnModel derived class, there will be no columns to show. This is why you get the empty table.


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