File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Vector and JTable" Watch "Vector and JTable" New topic
Author

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);
frame.setSize(Xsize,Ysize);
c=frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);


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


==================
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
Hi,

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


HTH

Stefan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector and JTable