Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2004, 01:11 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing JTable Navigational Key

I have programmed a JTable application. I want that if I press 'Enter' key in the JTable cell, the cell at right side may be selected. Similarly, when I press 'Enter' in the right most cell, the first cell of the next row may be selected.

In other words, I like 'Enter' key to behave as forward navigational key in JTable cells like 'Tab' key.

The following is the piece of code which is not working for me. Though, it changes selection border to the next cell on pressing enter, but the focus is not shifted and editing remains in the current cell.

//voucherTable is a JTable object.

Action moveForward = new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        int r=voucherTable.getSelectedRow();
        int c=voucherTable.getSelectedColumn();
        if(c==2){
             c=-1;
            r+=1;
        }
        voucherTable.changeSelection(r,c+1,false,false);
    }
};


voucherTable.getInputMap().put(KeyStroke.getKeyStr oke
                     (KeyEvent.VK_ENTER,0),"moveForward");
voucherTable.getActionMap().put("moveForward",
                                        moveForward);

Kindly advise me to solve the problem.

Thanks.


Raaheel





Similar Threads
Thread Thread Starter Forum Replies Last Post
JTable and DataBase: bringing data to JTable Rashmirathi Java Databases 0 November 19th, 2006 01:53 AM
Changing Primary Key Value semilemon C# 9 May 9th, 2006 07:19 PM
Questions about JTable chtiteuf Java GUI 0 May 22nd, 2005 07:02 AM
Runtime Population of a JTable Sandz Java GUI 1 February 28th, 2005 10:10 AM
Color the Cells of JTable bamboat_3 Java GUI 0 July 29th, 2003 07:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.