• Post Reply Bookmark Topic Watch Topic
  • New Topic

about DetailTableModel

 
roulong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package seepic;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.io.*;
import java.util.Vector;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
public class panel_tab extends JPanel
{
public panel_tab()
{
class DetailTable extends JTable
{
DetailTableModel model=new DetailTableModel();
public DetailTable()
{
setModel(model);
setShowGrid(false);
setRowHeight(18);

}
}
DetailTable detailTable = new DetailTable();
add(new JScrollPane(detailTable));
}

class DetailTableModel extends DefaultTableModel
{
public DetailTableModel()
{
File path=new File("c:/");
String[] filename=path.list();
Vector vec = new Vector();
for(int i=0;i<filename.length;i++)vec.addElement(filename[i]);
addColumn("name");
addRow(vec);
}
}
}
where error?
FOUND.000???
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"roulong" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

It would help if you described the error you are getting in more detail...

One thing I can point out is that you are adding only one column ( called "name" ) to your table model, then adding a row with a column for each file in your C:\ root directory.... If you are trying to add all your data to that column, I think you should be using :



Thanks! and welcome to the JavaRanch!

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!