The way I handle this is to define a simple class that handles the action on the row header, by calling the corresponding action on the main table. For obvious reasons this class is called RowHeaderActionProxy. When this is used, pressing the key in the row header produces the same behavior as when the key is pressed in the main table, because the main table actually handles the event.
1 2 package com.vizitsolutions.identitytable; 3 4 import javax.swing.AbstractAction; 5 import javax.swing.Action; 6 import java.awt.event.ActionEvent; 7 import javax.swing.JTable; 8 9 /** 10 * <p>$Id: $</p> 11 * 12 * Handle events by delegating the handling to the appropriate action in the 13 * main table. 14 * 15 * @author Alex Kluge 16 * @version $Revision: $, $Date: $ 17 */ 18 public class RowHeaderActionProxy extends AbstractAction 19 { 20 JTable mainTable; 21 Action action; 22 23 /** 24 * Creates a new instance of RowHeaderActionProxy. 25 * 26 * @param mainTable The main table, which correctly handles the action. 27 * @param action The action defined on the main table, used to delegate 28 * the action from the row header to the main table. 29 */ 30 public RowHeaderActionProxy(JTable mainTable, Action action) 31 { 32 this.mainTable = mainTable; 33 this.action = action; 34 } 35 36 /** 37 * Triggered when the action is performed on the row header. The source of 38 * the event is set to the main table, then the main tables action is invoked. 39 * 40 * @param event The event that triggered the action. 41 */ 42 public void actionPerformed(ActionEvent event) 43 { 44 // make the action look like it happened in the main table. 45 event.setSource(mainTable); 46 action.actionPerformed(event); 47 } 48 } 49 50 51