import java.awt.*; import javax.swing.*; import java.io.*; class Test { public static void main(String args[]) throws IOException { JFrame jf = new JFrame(); JPanel topPanel; JTable table; JScrollPane scrollPane; // Set the frame characteristics jf.setSize( 300, 200 ); // Create a panel to hold all other components topPanel = new JPanel(); topPanel.setLayout( new BorderLayout() ); jf.getContentPane().add( topPanel ); // Create columns names String columnNames[] = { "Column 1", "Column 2", "Column 3" }; // Create some data String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } }; // Create a new table instance table = new JTable( dataValues, columnNames ); table.setColumnSelectionAllowed(true); table.setRowSelectionAllowed(true); table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // Add the table to a scrolling pane scrollPane = new JScrollPane( table ); topPanel.add( scrollPane, BorderLayout.CENTER ); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.show(); } }