public FeatureTable(final Model model) { super(new FeatureTableModel(model)); FeatureTableSelectionModel ftsm = new FeatureTableSelectionModel(model); setSelectionModel(ftsm); setDefaultRenderer(String.class, new FeatureTableCellRenderer()); model.addObserver(this); this.model = model; listModel = (FeatureTableModel) this.getModel(); // setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // getColumnModel().getColumn(0).setPreferredWidth(200); for (int i = 1; i < this.getColumnCount(); i++) { getColumnModel().getColumn(i).setPreferredWidth(30); getColumnModel().getColumn(i).setMaxWidth(50); } getTableHeader().addMouseMotionListener(new ColumnHeaderToolTips(listModel)); getTableHeader().setReorderingAllowed(false); ToolTipManager.sharedInstance().setInitialDelay(0); addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 0) { Feature rf = listModel.getFeature(rowAtPoint(e.getPoint())); model.selectionModel().setLocationSelection(rf); if (e.getClickCount() > 1) { int min = rf.start(); int max = rf.end(); model.vlm.center((min + max) / 2); } } } }); }
public FeatureTableSelectionModel(Model model) { this.model = model; model.addObserver(this); }