how to navigate through jtable using up/down, pageup/page down keys?
843806Sep 27 2007 — edited Oct 11 2007hi friends,
I want to navigate through JTable using using up/down, pageup/page down keys.
My code is like this :
public class EditorBase extends JFrame{
...
}
public class Editor extends EditorBase {
private JTable myTable;
private JPanel myPanel;
private void initComponents() {
...
myPanel = new JPanel();
myTable = new JTable();
SetupListeners(); //setup all listeners
GridBagConstraints gridBagConstraints;
myPanel.setLayout(new GridBagLayout());
...
}
private void SetupListeners() {
final MouseListener TbList = new MouseAdapter() {
public void mouseClicked(MouseEvent Ev) {
RowSelected();
}
};
myTable.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {}
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
int Code = e.getKeyCode();
if (Code == KeyEvent.VK_UP || Code == KeyEvent.VK_DOWN || Code == KeyEvent.VK_PAGE_DOWN ||
Code == KeyEvent.VK_PAGE_UP || Code == KeyEvent.VK_HOME || Code == KeyEvent.VK_END)
{
TbList.mouseClicked(null);
}
}
});
myTable.addMouseListener(TbList);
}
}
In this case muse listeners are working fine but I am not able to navigate through mytable using up/down, pageup/page down keys.
Can anybody help me with this?
I am new to swing and also to this forum. I am not sure about how post code in thread. if anybody have guidelines for the same, please share those one.
thanks,
Ring