super (new BorderLayout());
myModel = m;
mySortableModel = new SortableTableModel (myModel);
mySortableModel.setComparatorForColumn (new MyColorComparator(), 2);
JTable table = new JTable (mySortableModel);
table.setDefaultRenderer (java.awt.Color.class, new ColorRenderer());
JScrollPane scroller =
new JScrollPane (table,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
table.setPreferredScrollableViewportSize (new Dimension (400, 200));
setLayout(new BorderLayout());
add (scroller, BorderLayout.CENTER);
// add sort buttons
JPanel buttonPanel = new JPanel();
sort1 = new JButton ("Sort 1");
buttonPanel.add(sort1);
sort1.addActionListener(this);
sort2 = new JButton ("Sort 2");
buttonPanel.add(sort2);
sort2.addActionListener(this);
sort3 = new JButton ("Sort 3");
buttonPanel.add(sort3);
sort3.addActionListener(this);
bonus = new JButton ("More data");
buttonPanel.add(bonus);
bonus.addActionListener(this);
add (buttonPanel, BorderLayout.SOUTH);