public void setSelectionInterval(int anchor, int lead) { super.setSelectionInterval(anchor, lead); int min = Math.min(anchor, lead); int max = Math.max(anchor, lead); // Table may be showing 0 bytes, but we're showing 1 row header if (max < table.getRowCount()) { table.setSelectedRows(min, max); } }
/** * Constructor. * * @param table The table displaying the hex content. */ public HexEditorRowHeader(HexTable table) { this.table = table; model = new RowHeaderListModel(); setModel(model); setFocusable(false); setFont(table.getFont()); setFixedCellHeight(table.getRowHeight()); setCellRenderer(new CellRenderer()); setBorder(new RowHeaderBorder()); setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); syncRowCount(); // Initialize to initial size of table. table.getModel().addTableModelListener(this); }
private void syncRowCount() { if (table.getRowCount() != model.getSize()) { // Always keep 1 row, even if showing 0 bytes in editor model.setSize(Math.max(1, table.getRowCount())); } }
public void removeSelectionInterval(int index0, int index1) { super.removeSelectionInterval(index0, index1); int anchor = getAnchorSelectionIndex(); int lead = getLeadSelectionIndex(); table.setSelectedRows(Math.min(anchor, lead), Math.max(anchor, lead)); }
public void addSelectionInterval(int anchor, int lead) { super.addSelectionInterval(anchor, lead); int min = Math.min(anchor, lead); int max = Math.max(anchor, lead); table.setSelectedRows(min, max); }