Results 1 to 3 of 3
  1. #1
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default listener for a jtable triggers twice

    hi, I am using a jtable to get the records displayed from my jdbc table. what I would like to do is after clicking a certain row, it will display another window showing more information about the clicked record but my problem is the action triggers twice

    Java Code:
    	jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    			    public void valueChanged(ListSelectionEvent e) {
    			        int sel = jTable.getSelectedRow();
    			        System.out.println("row clicked: " + sel);   
    			    }
    
    			});
    this one show the index of the selected row but it prints out the 'sel' variable twice.. I was wondering if I can just use another listener like a mousepressed event for the table if it is possible or is there still a fix for the code above so it will just trigger once?

  2. #2
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default

    update:

    when I use my arrow keys it triggers only once
    also when I just press the left mouse button (not releasing it) it will trigger once, and when I release the mouse button it will trigger again and I don't believe I have an action listener for the mousclicked or mousreleased event

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

Similar Threads

  1. Urgent:Jtable and key Listener
    By simmi in forum AWT / Swing
    Replies: 3
    Last Post: 02-02-2010, 05:56 AM
  2. JTable Cell Focus Listener
    By Manfizy in forum New To Java
    Replies: 1
    Last Post: 07-21-2009, 08:08 AM
  3. Make specific cell a hyperlink (triggers event)
    By javanewbie in forum AWT / Swing
    Replies: 3
    Last Post: 06-21-2009, 03:26 AM
  4. add an undo listener to a Jtable
    By christina in forum Advanced Java
    Replies: 12
    Last Post: 01-29-2009, 07:47 AM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •