Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

fireTableStructureChanged

Thread view: 
soup_or_power@yahoo.com - 22 Nov 2005 17:39 GMT
Hi
My code reorder columns and calls fireTableStructureChanged. But it
doesn't work. All I see is the default order of columns. Please see the
code below. Thanks for your help

for(int i=0;i<count;i++) {

                       int width=(int)(ttsDefaults.getColumnWidth(i)*

                    DesktopEnvironment.getInstance().getDesktopRootFrame().getWidth());

                       sumWidth+=width;

                       String name= (String) (ttsDefaults.getColumnName(i));

                treeTable.getColumnModel().getColumn(i).setPreferredWidth(width);

                treeTable.getColumnModel().getColumn(i).setHeaderValue(name);

                       System.out.println(" i=" + i + " name=" + name +
"**********");

                       //treeTable.setAutoCreateColumnsFromModel( false );

                       //treeTable.getColumnModel().getColumn(i).setWidth(width);

                   }

                   treeTable.getTableModel().fireTableStructureChanged();
soup_or_power@yahoo.com - 22 Nov 2005 22:16 GMT
I am able to get some partial results using JTable's moveColumn method.
I am posting the partially done method. I don't know how to improve it
so it works like bullet proof. I'd appreciate any help from the
audience here.

for(int i=0;i<count;i++) {

                       int width=(int)(ttsDefaults.getColumnWidth(i)*

                    DesktopEnvironment.getInstance().getDesktopRootFrame().getWidth());

                       sumWidth+=width;

                       String name= (String) (ttsDefaults.getColumnName(i));

                treeTable.getColumnModel().getColumn(i).setPreferredWidth(width);

                //treeTable.getColumnModel().getColumn(i).setHeaderValue(name);

                       //System.out.println(" i=" + i + " name=" + name +
"**********");

                       int s1=0;

                       String hd=(String)
treeTable.getColumnModel().getColumn(i).getHeaderValue();

                       System.out.println(" name= " + name + " modelhdr=" + hd +
"**********" + "iter=" + i);

                       if (name.trim().equals("") == false && name.equals(hd) ==
false) {

                           System.out.println("these two should be swapped");

                       for (int j=0; j <
treeTable.getTableModel().getColumnCount(); j++)

                       {

                           String n1= (String)
treeTable.getColumnModel().getColumn(j).getHeaderValue();

                           if (name.trim().equals("") == false && name.equals(n1) ==
true) {

                                   s1=j;

                            //treeTable.getColumnModel().getColumn(i).setHeaderValue(name);

                                   System.out.println("origplace=" + s1 +
"**************of" + n1 + " now at " + i);

                                   break;

                           }

                       }

                           //System.out.println("xml val=" + i + " modelval = " +
s1);

                       }

                       if (s1 > 0)

                       {

                               System.out.println("swapping columns" + i + " " + s1);

                               treeTable.moveColumn(i, s1);

                               //treeTable.moveColumn(s1, i);

                               treeTable.revalidate();

                       }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.