Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector and JTable

 
nikos sokaf
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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


HTH

Stefan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic