Hi, I'm relatively new to Java and here's what i want to do, i want to be able to insert what i type in the text field into the JTable. Just a very basic function. But i'm having problems with JTable. I used the Netbeans IDE GUI editor so there are some protected codes that i cannot alter. If i code the interface manually, the Jtable works fine. However, if i add JTable implementation to the GUI i created, it doesn't work. Thing is, this is just a part of a bigger application that already has the GUI designed nicely via Netbeans GUI editor. Here, i'm just trying to get the column names to show but they won't. I've already read the sun tutorials and the how to use JTables tutorial but as i've said, when i incorporate it in the codes generated by Netbeans UI editor, it won't work. When i do add the components to a frame manually, it works. My codes are as follows:

* tryTable.java
* Created on February 11, 2008, 5:51 PM

package trial_codes;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.util.*;
import javax.swing.event.*;

* @author LIMDE
public class tryTable extends javax.swing.JFrame {

Vector rows,columns;
DefaultTableModel tabModel;

/** Creates new form tryTable */
public tryTable() {

rows = new Vector();
columns = new Vector();
String[] columnNames =

tabModel = new DefaultTableModel();
tabModel.setDataVector(rows, columns);

//jScrollPane1 = new JScrollPane(tbl1);


public void addColumns(String[] colName)//Table Columns
for (int i = 0; i < colName.length; i++) {
columns.addElement((String) colName[i]);

public void addRow() //Add Row
Vector r = new Vector();
r = createBlankElement();


public Vector createBlankElement() {
Vector t = new Vector();
t.addElement((String) " ");
t.addElement((String) " ");
t.addElement((String) " ");
t.addElement((String) " ");
t.addElement((String) " ");
t.addElement((String) " ");
t.addElement((String) " ");
return t;

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

txtFld1 = new javax.swing.JTextField();
txtFld2 = new javax.swing.JTextField();
btnAdd = new javax.swing.JButton();
pnlTbl = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tbl1 = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);



javax.swing.GroupLayout pnlTblLayout = new javax.swing.GroupLayout(pnlTbl);
pnlTblLayout.createParallelGroup(javax.swing.Group Layout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
pnlTblLayout.createParallelGroup(javax.swing.Group Layout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(pnlTbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtFld1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addComponent(txtFld2, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addContainerGap(51, Short.MAX_VALUE))
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(txtFld1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtFld2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addComponent(pnlTbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(20, Short.MAX_VALUE))

}// </editor-fold>

* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tryTable().setVisible(true);
//tryTable t1 = new tryTable();

// Variables declaration - do not modify
private javax.swing.JButton btnAdd;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JPanel pnlTbl;
private javax.swing.JTable tbl1;
private javax.swing.JTextField txtFld1;
private javax.swing.JTextField txtFld2;
// End of variables declaration