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 / GUI / November 2005

Tip: Looking for answers? Try searching our database.

Does fireTableStructureChanged work on JTreeTable

Thread view: 
soup_or_power@yahoo.com - 22 Nov 2005 19:48 GMT
I've tried every fire method on a JTreeTable after calling
setHeaderValue to reorder columns but it refuses to reorder the
columns.

Here is some sample code:

                                    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.getTableModel().fireTableStructureChanged();

                  treeTable.getTableModel().fireTableDataChanged();
soup_or_power@yahoo.com - 22 Nov 2005 22:17 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.