Hi All,

I am having a JTable which runs so strange. Jtable is very basic having three rows and three columns.

If I use SetValue method to place data in any cell and run the program JTable is not visible.

If i delete the SetValue Method from the program and run it, it diplays the JTable correctly.

public class TableTest {

    static JTable table ;
    public TableTest() {
        // TODO Auto-generated constructor stub

        JFrame jFrm = new JFrame("simple table");
        jFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrm.setVisible(true);
        jFrm.setSize(500,300);
        jFrm.setLayout(new FlowLayout());

         table = new JTable(3,3);


        table.setPreferredScrollableViewportSize(new Dimension(500,30));

        table.setValueAt("Apple", 1, 3); \\if I delete this line, prog becomes visible 

        JScrollPane scroll = new JScrollPane(table);

        jFrm.add(scroll);
        jFrm.pack();

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        TableTest reference = new TableTest();

    }

}
This question has already been answered. Start a new discussion instead.