Results 1 to 3 of 3
  1. #1
    Stephen Douglas's Avatar
    Stephen Douglas is offline Senior Member
    Join Date
    Mar 2010
    Posts
    137
    Rep Power
    0

    Default right clicking JTable row

    When I left click a row in the Jtable the row is set to focus... but when I right click a row in the Jtable.. that particular row doesn't seeks any focus.

    How can I make it possible? please suggest:(
    The Quieter you become the more you are able to hear !

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

    Default

    Add your own listener to do the selection. Something like:

    Java Code:
    table.addMouseListener( new MouseAdapter()
    {
    	public void mouseReleased(MouseEvent e)
    	{
    		if (e.isPopupTrigger())
    		{
    			JTable source = (JTable)e.getSource();
    			int row = source.rowAtPoint( e.getPoint() );
    			int column = source.columnAtPoint( e.getPoint() );
    
    			if (! source.isRowSelected(row))
    				source.changeSelection(row, column, false, false);
    		}
    	}
    });

  3. #3
    Stephen Douglas's Avatar
    Stephen Douglas is offline Senior Member
    Join Date
    Mar 2010
    Posts
    137
    Rep Power
    0

    Default

    It worked Thanks..
    The Quieter you become the more you are able to hear !

Similar Threads

  1. Double-clicking .jar files?
    By StokedOnMe in forum New To Java
    Replies: 10
    Last Post: 03-27-2014, 10:16 PM
  2. Clicking on an oval in JPanel
    By chielt in forum Java 2D
    Replies: 6
    Last Post: 03-17-2010, 12:08 AM
  3. Auto Clicking Application
    By dpedroia15 in forum New To Java
    Replies: 6
    Last Post: 03-02-2010, 09:35 PM
  4. Sorting in JTable without clicking on column headers
    By ProgrammingPup in forum Advanced Java
    Replies: 6
    Last Post: 11-04-2009, 05:26 AM
  5. Java3D: Clicking and getting coordinates?
    By seabhcan in forum Advanced Java
    Replies: 0
    Last Post: 01-11-2008, 02:46 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
  •