i’m trying to add a jtable component to my jPanel but i am unable to see it. What am i doing wrong?.
table gui = new table(data,colum);
mainPanel.add(gui.table);
class table extends JFrame
{
public JTable table;
public table(Vector data, Vector colum)
{
setLayout(new FlowLayout());
table = new JTable(data,colum);
table.setPreferredScrollableViewportSize(new Dimension(900,10));
table.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(table);
add(scrollPane);
}
}
Extending JFrame seems odd; you don’t use any of the top level container capabilities. Here’s an example that extends JPanel, with a main() that drops the panel into a JFrame.
–Edited to accept an existing JPanel