1
的祖先我實現發現,如果我的組件是其他部件
@Override public boolean dispatchKeyEvent(KeyEvent e)
我JScrollPane中
。
當我評估
e.getSource()
我得到的JTable,JScrollPane的下方。
我怎麼知道它在我的層次結構中?
(我調用其他JScrollPane的功能,通過該KeyEvent,我不想遞歸)
的祖先我實現發現,如果我的組件是其他部件
@Override public boolean dispatchKeyEvent(KeyEvent e)
我JScrollPane中
。
當我評估
e.getSource()
我得到的JTable,JScrollPane的下方。
我怎麼知道它在我的層次結構中?
(我調用其他JScrollPane的功能,通過該KeyEvent,我不想遞歸)
您是否在尋找這個?:
SwingUtilities.getAncestorOfClass(JScrollPane.class, jtable);
或者,如果你要檢查一個給定的實例:
SwingUtilities.isDescendingFrom(jtable, aParentOfJTable);
如果不是,那麼我不明白你的問題。
謝謝。 SwingUtilities.isDescendingFrom(jtable,aParentOfJTable); 這爲我做了詭計 – Jeb 2012-04-23 15:24:37
你真的想做什麼?重寫dispatchKeyEvent通常是不必要的,也是錯誤的做事方式。 – 2012-04-23 14:15:39
試圖做到這一點 http://stackoverflow.com/questions/10282064/moving-scrolling-up-and-down-on-three-jtable-simultanously – Jeb 2012-04-23 14:25:25