String[] columnNames = {"Name", "Age", "Gender"}; Object[][] data = {{"John", 25, "Male"}, {"Jane", 30, "Female"}, {"Bob", 20, "Male"}}; JTable table = new JTable(data, columnNames);
String[] columnNames = {"Name", "Age", "Gender"}; Object[][] data = {{"John", 25, "Male"}, {"Jane", 30, "Female"}, {"Bob", 20, "Male"}}; JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table);
String[] columnNames = {"Name", "Age", "Gender"}; Object[][] data = {{"John", 25, "Male"}, {"Jane", 30, "Female"}, {"Bob", 20, "Male"}}; JTable table = new JTable(data, columnNames); table.getColumnModel().getColumn(0).setPreferredWidth(100); // Set the width of the first column table.getTableHeader().setReorderingAllowed(false); // Disallow column reorderingOverall, javax.swing JTable is a powerful GUI component that can be customized to fit various data display needs.