I would like to display a table of incoming packets and their attributes. Does JTable allow me to add rows dynamically? The only way I have been able to update the view is to construct a new table object.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
yes you can manipulate the underlying model of the JTable. The model is where the data is kept and it gets queried by the JTable for the different cell contents. You can manipulate the model either by using
JTable.setModel(...)or by implementing your own TableModel and manipulating it’s data directly which is a fairly easy task with lots of tutorials on the web. You just have to make sure that the JTable gets updated when you change the model, which is easyily achieved by aJComponent.pack()or similar methods.check here for some tutorials:
http://download-llnw.oracle.com/javase/tutorial/uiswing/components/table.html
http://www.javalobby.org/articles/jtable/
http://www.java2s.com/Code/Java/Swing-JFC/TableModelExample.htm
http://www.codetoad.com/java_JTable.asp
hope that helped…