[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Mouse double click event in JTable

Posted on 2004-11-11
4
Medium Priority
?
570 Views
Last Modified: 2012-06-27
Hi, this is quite difficult to explain!
  I have a JTable.  When the user double clicks a row it opens the file represented by that row:

public void mousePressed(MouseEvent e)
  {
    // if a double click then update the collection view
    if (e.getClickCount() == 2)
    {
      Point origin = e.getPoint();
      int row = table.rowAtPoint(origin);
      if (row != -1)
      {
        /** openFile( row ); */
      }

So this file is opened in the work-area "panel" (dockable frame) below the table -> the last thing done is to activate (give focus to) this new file.
But then the focus jumps back to the tables frame - where the mouse-event occurred.
I can see how there is logic to this alright, but there is an anomoly which might help in providing a solution here:

if the cell that was double clicked IS editable, then the focus remains with the opened document*, if it IS NOT editable then focus jumps back to the table!

* NB! the focus stays with the opened document but in the table it looks like cell editing was cancelled or something (the specific cell has an edit box around it, but the cursor is not blinking because focus isnt even on that panel!)

Any ideas !?i?!
Cathal.
0
Comment
Question by:cathalmchale
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12560780
Try queueing the request for focus using EventQueue.invokeLater().
0
 

Author Comment

by:cathalmchale
ID: 12566083
OK - ill try.  how?? !!
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 12569585
EventQueue.invokeLater(new Runnable()
{
   public void run()
   {
      // add your code here
   }
});
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question