Results 1 to 4 of 4
- 03-08-2009, 04:53 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
How to add new row from JTable comp in netbeans GUI?
In these 2 days i had been trying to understand the jTable in order to add new rows in runtime GUI and so far not successful. went through the tutorial from sun tutorial website
and seems like the tutorial is not using a comp from the pallette in netbeans but creating a new table from scratch. I'm trying to build a GUI and use the jTable as one of the comp. This is different from the tutorial. Since that the jTable comp had been provided, why i still need to create the table from scratch? Can i just use the component? If anyone have idea pls advise..
thanks
z
- 03-08-2009, 05:32 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
This is one of the bad results developers comes with who start work from such IDEs, rather not working from the basis.
In runtime, you have to do the same thing that tutorial explain. You cannot change any properties on the palette at runtime on NetBeans. Go through the tutorial carefully and try to workout a simple application first.
- 03-09-2009, 06:50 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Hello,
Yes, it is very painful to start directly to GUI. Anyway, i redo back the concept from
http:--java.sun.com-docs-books-tutorial-uiswing-components-table.html#show (i replaced / with -)
what i understand, i need to create a table model. But when using GUI, it had been declared automatically when the jTable comp drag to the jForm as under
@SuppressWarnings("unchecked")
private void initComponents() {
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"rs1", "rs2", "rs3", "rs4"
}
));
jScrollPane1.setViewportView(jTable1);
Ok, seems like it had created the table method as DefaultTableModel for it and i believe it is fine now. So i don't need to redo the table method creation. To add a row.. when i check DefaultTableModel class there is a method called addRow(Object[] rowData) - Adds a row to the end of the model.
Everytime i tried to write jTable.addRow() ... it will have problem. It will now allow me to proceed. I don't really understand here. The table model had been generated and why the addRow method is not able to use from it. Am I missing something here?
Let me know if I'm still wrong. I just need to add a row to the jTable1 comp which i had dragged to the jForm.
Thanks
Z
- 03-09-2009, 07:37 AM #4
Similar Threads
-
Netbeans Jtable
By Manfizy in forum NetBeansReplies: 16Last Post: 11-13-2008, 09:15 AM -
get IP from other comp in LAN
By hungleon88 in forum NetworkingReplies: 2Last Post: 09-20-2008, 01:21 PM -
Row Name In Jtable
By SANDY_INDIA in forum AWT / SwingReplies: 1Last Post: 08-16-2008, 12:23 AM -
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05-15-2008, 10:15 AM -
JAVA software solutions:For AP Comp. Science (Lewis,Loftus,Cocking)
By padutch in forum New To JavaReplies: 4Last Post: 11-27-2007, 11:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks