CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    103

    How to set the size of a column in a Table?

    size or relative size

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163
    Get the desired TableColumn and then you can set the max width, min width, preferred width, and width:
    Code:
    TableColumn column = myTable.getColumn(foo);
    // or
    // TableColumn column = myTable.getColumnModel().getColumn(index);
    column.setMaxWidth(...);
    column.setMinWidth(...);
    column.setWidth(...);
    column.setPreferredWidth(...);
    // etc.
    There are no 'accidents', only human errors and failings...
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Jan 2003
    Posts
    103
    foo stands for what??>

  4. #4
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    The identifier object for your Column.
    Which one getColumn should return.

  5. #5
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163
    cntomcom - the first thing you should do when you have a question about a class method is look at the JavaDoc for that class method, e.g. JTable.getColumn(...). In some cases (like this one), it may still not be clear what is meant, so you follow (where possible) the clues to related classes, e.g. TableColumn. A little persistence and common sense will generally lead you to an explanation, e.g. TableColumn.getIdentifier().

    This process is absolutely essential if you want to be a successful Java programmer, so it is important that you become familiar with the JavaDocs. Knowing how and where to find the information you need is probably the single most important aspect of practical programming.

    There's no doubt that cowardice can be a life saver...
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

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