File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Vector and JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Vector and JTable" Watch "Vector and JTable" New topic

Vector and JTable

nikos sokaf
Ranch Hand

Joined: May 01, 2004
Posts: 57
Hi ranchers again!
first of all i wanna thanks Greg for his help.
I had posted a problem with a JTable a fiew days ago:
My code was:
public class TableDeamon implements ActionListener{
private Object columnnames[];
private Object data[][];
private JTable table;
private Container c;
private JButton cancel,save; sigouro an einai oristika ayta
private JPanel buttonPanel;
public String Title="New Window.";
private JFrame frame;
private int returnXlayout, returnYlayout;
public String TableName;

public void setup(int Xsize,int Ysize,int CloseOperator){
frame=new JFrame(Title);

table=new JTable(data, columnnames);
c.add( table , BorderLayout.CENTER) ;
c.add( new JScrollPane ( table ) );

With this code i wanted to add a row during on runtime, by pressing a button.The row i wanted has not values.

Greg suggested me to use DefaultTableModel, store data in there and then add to table the dtm (Default Table Model) to JTable.

I used .table.DefaultTableModel import and worked, but i cant saw the empty new row by clicking my button (and using the dtm.addNew() method).I tried to use Vector but i had no result!

Please give my your help!

Thanks to Greg ,

Thanks anyone for your help, if any!
Stefan Krompass
Ranch Hand

Joined: Apr 29, 2004
Posts: 75

you could try implementing your own TableModel as a subclass of DefaultTableModel (untested):


I agree. Here's the link:
subject: Vector and JTable
It's not a secret anymore!