0

I want to have a JTable for representing a CSV file with both row as well as column headers, just like MS Excel provides, which are initially set as att1, att2, att3 (for column headers) and row1, row2, row3 (for row headers). I need to have such an interface where header values could be set if they are already present in a file.

If the first column contains header values,then instead of row1, row2, row3, given values could be set as row headers, and, if the first row contains header values,then instead of att1, att2, att3 given values could be set for column.

I don't know how to do the same with row. for columns,

String[] hname = new String[dm.getColumnCount()];
    for(int j=0;j<dm.getColumnCount();j++)
   {       
   hname[j]=dm.getValueAt(0, j).toString();}
    dm.removeRow(0);
    Vector<String> v = new Vector<String>(Arrays.asList(hname));
    dm.setDataVector(dm.getDataVector(), v);
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user3181652
  • 34
  • 1
  • 5
  • 1
    Use a consistent and logical indent for code blocks. The indentation of the code is intended to help people understand the program flow. – Andrew Thompson Jan 18 '14 at 21:39

1 Answers1

0

Try googling JTable Row Header:

JTable Row Header Implementation

http://www.java2s.com/Code/Java/Swing-Components/TableRowHeaderExample.htm

Community
  • 1
  • 1
Peter Quiring
  • 1,648
  • 1
  • 16
  • 21