DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Please Help! I am meeting a deadline and i still haven't figured this out....

  1. #1
    Join Date
    Sep 2005

    Unhappy Please Help! I am meeting a deadline and i still haven't figured this out....

    Hi All!

    I am working on a project and the deadline is really fast approaching... I have been trying to solve this problem for weeks and I still havn't figured this out. I'm not really that familiar with swing, and I have been stucked in a JTable limbo.

    My JTable implements single row/column selection, cells are editable, and has Double values in it. I wanted my JTable to behave in such a way that whenever I press <ENTER>, it will select(or focus) the next cell on the right or when it is already at the end of the column, it will select the cell of the first column below. The default behaviour of JTable is that It selects(or focuses) the next cell below, and so on and so forth...

    Another problem also is that when I try to edit the values on the cells, by pressing a key on the keyboard, it appends the character at the end of the existing value. How do I override it that instead of appending it, it will replace the existing value.

    I couldn't find a way to figure this thing out... please help...

  2. #2
    Join Date
    Dec 2005
    New Jersey
    I'd add a KeyListener to the JTable to listen for when they press enter.

    You must implement it at the top (public class MyClass extends JApplet, implements KeyListener)
    and add it to the instance of JTable (table.addKeyListener( this )) and add the following methods:
    public void keyPressed( KeyEvent ke ) { }
    public void keyTyped( KeyEvent ke ) { }
    public void keyReleased( KeyEvent ke ) { }
    So you would probably want to do this in one of those methods:
    if ( ke.getKeyCode() == KeyEvent.VK_ENTER ) {
    // code to set focus the specific cell
    Last edited by destin; 12-26-2005 at 10:59 PM.

  3. #3
    Join Date
    Sep 2005

    Not what I meant

    I was looking for sum code to override the Selection mechanism of JTable... I hope I find any...

Similar Threads

    By A_Bantom in forum VB Classic
    Replies: 1
    Last Post: 06-16-2000, 04:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center