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.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);



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

        TableTest reference = new TableTest();


Re: JTable is not displaying data using SetValueAt method. 80 80

Oops, got it. its a silly mistake. Column size exceeded.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.