views:

124

answers:

4

hi, all in title

thanks for your answers

+1  A: 

Have you tried to google?

Sun-Tutorial How to Use Tables should have everything you need.

Peter Lang
+2  A: 
JTable table = new JTable();
JScrollPane spTable = new JScrollPane(table);
JPanel panel = new JPanel();

panel.add(spTable);

There is a comphrensive guide about how to layout swing components, you should consider Pyrolistical link..

Jack
+1  A: 

Imports and table model left as an exercise to the user of this code. Also, the panel layout is arbitrarily chosen for simplicity.

public class JTableDisplay {
    public JTableDisplay() {
        JFrame frame = new JFrame("JTable Test Display");

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());

        JTable table = new JTable();

        JScrollPane tableContainer = new JScrollPane(table);

        panel.add(tableContainer, BorderLayout.CENTER);
        frame.getContentPane().add(panel);

        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        new JTableDisplay();
    }
}

The scroll pane is fairly important to note. Without it, your table won't have a header or scroll if the content becomes larger than the display.

justkt