Viewing JTable on panel

I have been trying to use the new GUI design in IDEA 4
and have been trying get some information in to JTable that is on a Panel but it doesn't seem to work. Can anyone she what I am doing wrong?

Comment actions Permalink

Try adding the JTable element to the primary form and lay it out in a grid, either horizontally or vertically. When doing this, it places it within its own JPanel object within the primary panel.

Bind the JTable to its associated object within the binding class; then set the TableModel containing the data/header information and it should display properly.

Hope this helps...

Comment actions Permalink

This works for getting the table to show up, but the table header does not display. What's the best way to do this, without using a scrollport?

Comment actions Permalink

Modify below code to suit ur needs

int rows = 10;
int cols = 5;
JTable table = new JTable(rows, cols);
JTableHeader header = table.getTableHeader();

container.setLayout(new BorderLayout());

// Add header in NORTH slot
container.add(header, BorderLayout.NORTH);

// Add table itself to CENTER slot
container.add(table, BorderLayout.CENTER


Please sign in to leave a comment.