Skip to content

Instantly share code, notes, and snippets.

@CeramicTitan
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CeramicTitan/15344b447d5b17996d48 to your computer and use it in GitHub Desktop.
Save CeramicTitan/15344b447d5b17996d48 to your computer and use it in GitHub Desktop.
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Student Ranks", TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel_1.setBounds(6, 0, 534, 421);
frame.getContentPane().add(panel_1);
panel_1.setLayout(null);
String[] columnNames = {"Names","Level"};
Object[][] data = utils.populateTable();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(6, 18, 522, 396);
panel_1.add(scrollPane);
table = new JTable(data, columnNames);
TableRowSorter sorter = new TableRowSorter(table.getModel());
sorter.setComparator(1, new CustomComparator());
table.setRowSorter(sorter);
scrollPane.setViewportView(table);
table.setFillsViewportHeight(true);
}
public class CustomComparator implements Comparator<String>{
String[] levels = {"Black", "Brown","Green","Blue","Yellow","White"};
@Override
public int compare(String o1, String o2) {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment