Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JTable column widths reverting to defaults?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JTable column widths reverting to defaults?

    I have a form with 3 JTables on it. The first two are working fine, but the third is resetting to default column widths after the data structure is updated and a fireTableStructureChanged() occurs.

    Can anyone tell me what would cause the table to reset to default widths? I'm setting minWidth, maxWidth and preferredWidth (trying to be complete).

    I'd like some debug ideas. I'm setting the width values all over the place trying to find why it keeps reverting. I've even tried setting them in a PropertyChangeListener on the minWidth variable.


    Any help would be greatly appreciated.

    Thanks in advance!
    -Will


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: JTable column widths reverting to defaults?

    What layout are you using? What's a form? Better yet: post an SSCCE (not your whole program) demonstrating what's going on, so we can play with it ourselves.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JTable column widths reverting to defaults?

    Oops. I meant "Frame", not form. That's what I get for typing too fast.
    I will try to get a SSCCE together, but in the mean time do you happen to know what might cause the columns might revert back to default widths?

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JTable column widths reverting to defaults?

    Okay, I found my problem. For anyone else having this kind of problem. The fireTableStructureChanged() caused the information to be wiped from the columns. Every time I execute this method I have to be sure I go back and setup my columns again.

    BUT, it would be easy to do this if I could have a listener that is called when this method is called. Haven't figured this one out yet.

Similar Threads

  1. Sync changing column widths across multiple JTables
    By eewill in forum AWT / Java Swing
    Replies: 1
    Last Post: January 17th, 2012, 10:42 AM
  2. change JTable column name, gui does not update at once
    By renars in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 23rd, 2011, 10:39 AM
  3. [SOLVED] how to get the row and column of a component gridlayout
    By prettynew in forum AWT / Java Swing
    Replies: 0
    Last Post: March 13th, 2011, 06:39 PM
  4. [SOLVED] Quick JTable Column Sort Question
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 15th, 2010, 04:35 PM
  5. Highlighting both row and column in JTable
    By bschneider14 in forum AWT / Java Swing
    Replies: 4
    Last Post: May 29th, 2010, 09:14 AM