I am using a JFrame & JPanel to create a frame.JFrame contains comboboxes,CheckBoxes,JLabels etc.Layout of JPanel is set to "null",because i am using setBounds(int,int,int,int) to set the position of components on JFrame.
There is also a JButton(named as "Submit").On submit button i have added actionListener,so that if i click on this button,A table will generate on frame(at runtime).
JTable is successfully displaying on JFrame but Table columns name are not displaying along with JFrame(Only table data is displaying when submit button is pressed).
I am also using setBounds with JTable.What should i have to do in this case ?
submitButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Object ColumnName[] = {"Document Name", "Modified Date", "Size(in MB)"};
Object data[][] = { {"test.txt", "24-Oct-2011", "540"}};
table = new JTable(data,ColumnName);
table.setBounds(20,230,330,100);
panel.add(table);
panel.repaint();
panel.revalidate();
}
});
Give me your all valuable suggestions soon. Thank you.