swing - Java: JTable not showing icons properly -


In my application, I have to display the file system file in JTbables. When I click on Jetri node (which is a system folder), then the content of that folder is shown in JTable.

In the first column of JTable (where the name of the file or folder icon is shown), the icon is obtained from the system icon and displayed. Everything is working fine, however, the problem is that when the renderer renders the icon, then the first line icon (the first line of the jetties) is repeated in all the rows. I mean that the icon does not convert to JTable later rows. Here is my code in which a render icon appears and the model displays in JTable

  class KeyIconCellRenderer DefaultTableCellRenderer {public KeyIconCellRenderer (string Ext) {File file = new file (ext); Icon icon = FileSystemView.getFileSystemView (). GetSystemIcon (file); SetIcon (icon); }}   

And here's the code where I'm using the render to display

  applies the Private class selection to TreeSelectionListener {Public Zero Value Converted (tree SELECTEVE e) {object [] MyData = new object [6]; TreePath Path = E.Getpath (); FileUtil util = new FileUtil (); File metadata metadata; Of vector & lt; FileMetaData & gt; VList = new vector & lt; FileMetaData & gt; (); DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeMainView.getLastSelectedPathComponent (); FileInfo info = (FileInfo) node .getUserObject (); File file = path. VList = util.getChildList (filepath); DtModel.getDataVector () removeAllElements () .; For (int i = 0; i   

In the enclosed image, the fist icon of the fist file is repeated in all the rows,

Please help, this will be a great favor, thanks

screen shot

[While presenting the current icon in the renderer's constructor, it is necessary to reset the table column renderer in the loop at each time. As a result, the file-icon is used for everyone.

The basic problem is that you do not seem to fully understand the concept of one: it is to display cell data because it is given as a parameter in the xCellRendererComponent So there's space to see the icon to use it. The way to go is to store the file object in the table cell and ask the method every time with the appropriate icon.

Cheers Genet

Comments