Results 1 to 6 of 6
  1. #1
    suresh.uvce is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default Regarding the JTable

    I an New to Java

    I want to display the Contents of the Directory inside the JTable
    when I select the Directory.

    Please help in this Regads

    Regards

    Suresh.P

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

  3. #3
    suresh.uvce is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    Hai All,

    I get the code to display the Icon on the Frame, but i want to
    display onto the Particular Row.

    For that I am sending the Path of the file and return the Icon to the case stmt
    where I can display the Icons, but it is Displaying the String of that Particular
    File of Sirectory.

    What is the Solution for this.

  4. #4
    suresh.uvce is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    Hai All,

    I get the code to display the Icon on the Frame, but i want to
    display onto the Particular Row in the Table.

    For that I am sending the Path of the file and return the Icon to the case stmt
    where I can display the Icons, but it is Displaying the String of that Particular
    File of Sirectory.

    What is the Solution for this.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    To clarify your problem, how about posting a small but compilable program that demonstrates what you've tried and the problems you're having with it. If we can actually see and modify the code, it will greatly increase our understanding of your problem. Best of luck.

  6. #6
    suresh.uvce is offline Member
    Join Date
    Feb 2009
    Posts
    5
    Rep Power
    0

    Default

    import javax.swing.*;
    import javax.swing.table.*;
    import java.io.File;
    import java.util.Date;
    import javax.swing.filechooser.FileSystemView;

    class FileTableModel extends AbstractTableModel {

    protected File dir;
    protected String[] filenames;

    protected String[] columnNames = new String[] {
    "", "Icon", "File Name", "File Size", "Date Created"
    };

    protected Class[] columnClasses = new Class[] {

    Boolean.class, Long.class, String.class,
    Long.class, Date.class
    };


    public FileTableModel(File dir) {
    this.dir = dir;
    this.filenames = dir.list();
    }


    public int getColumnCount() { return 5; } // A constant for this model
    public int getRowCount() { return filenames.length; } // # of files in dir

    // Information about each column.
    public String getColumnName(int col) { return columnNames[col]; }
    public Class getColumnClass(int col) { return columnClasses[col]; }

    // The method that must actually return the value of each cell.
    public Object getValueAt(int row, int col) {
    File f = new File(dir, filenames[row]);
    System.out.println(filenames[row]);


    switch(col) {
    case 0: return Boolean.FALSE;
    case 1: return Icon_Recover();
    case 2: return filenames[row];
    case 3: return new Long(f.length());
    case 4: return new Date(f.lastModified());
    default: return null;
    }
    }
    Icon Icon_Recover(){

    /*File file = new File(str);
    Icon icon = FileSystemView.getFileSystemView().getSystemIcon(f ile);*/

    String s = "C:/Documents and Settings/suresh.uvce/Desktop/image001.jpg";
    File file = new File(s);

    // Get metadata and create an icon
    Icon icon = FileSystemView.getFileSystemView().getSystemIcon(f ile);
    return icon;
    }
    }

Similar Threads

  1. Regarding JTable
    By adeeb in forum AWT / Swing
    Replies: 12
    Last Post: 06-19-2008, 07:39 AM
  2. Regarding JTable
    By adeeb in forum SWT / JFace
    Replies: 0
    Last Post: 06-18-2008, 06:13 PM
  3. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  4. How to add in a new row in Jtable?
    By Ry4n in forum AWT / Swing
    Replies: 0
    Last Post: 01-18-2008, 12:26 PM
  5. Help with JTable
    By fernando in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •