Hello guys..
i need a help.. m new in java swings.. m using netbeans to create one application..
here i have to insert a new jtable at runtime.. like when a click on a button jtable should be inserted.. how can i do that in netbeans.? please help..

//Table declaration somewhere in the text
JTable myTable = null;

showTableBtn.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
        //use any of the 7 constructors
        myTable = JTable(Object[][] rowData, Object[] columnNames);
        SOME_OBJECT.add(myTable);
    }
});

SOME_OBJECT can be JPanel or any other subclass of Container.

I have already tried that but its not getting added.. i have tried to add label but it doesnt work too.. i have tried like this..

JLabel l = new JLabel("Hello");
jPanel1.add(l);
l.setVisible(true);
jPanel1.validate();
jPanel1.repaint();

Post your code

Be a part of the DaniWeb community

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