Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / July 2004

Tip: Looking for answers? Try searching our database.

Doble click on a JTable

Thread view: 
alexjcasol - 30 Jul 2004 17:35 GMT
Hi all,
does anyone know how to handle the double click event on a JTable?

I wrote the following code:

table.addMouseListener(new MouseAdapter()
{
    public void mouseClicked(MouseEvent e)
    {
        if (e.getClickCount() == 2)
                  some_statement;
    }                       
});

but it works only if I click on the  lines of the table and it doesn't if
I click in the middle of a cell.
Murray - 30 Jul 2004 18:08 GMT
> Hi all,
> does anyone know how to handle the double click event on a JTable?
[quoted text clipped - 12 lines]
> but it works only if I click on the  lines of the table and it doesn't if
> I click in the middle of a cell.

Hmm doesn't seem like a database problem .. maybe you should try
comp.lang.java.gui ;-)
alexjcasol - 30 Jul 2004 23:27 GMT
Got it!
The metter is the doubleClick on a cell.
By the double click you get the cell opened in edit mode and you loose the
control.
But if you check the Release event you get the control again just because
it happens after the click.
That's why it worked on the lines of the grid and it didn't on the cells.
I wrote the following code and it works.

table.addMouseListener(new MouseAdapter()
{
    public void mouseReleased(MouseEvent e)
    {
        if (e.getClickCount() == 2)
        {
            table.getCellEditor().stopCellEditing();
            My.Statement;
        }
    }
});

thank you for your kindness!
By Alessandro
Christophe Vanfleteren - 30 Jul 2004 22:46 GMT
> Hi all,
> does anyone know how to handle the double click event on a JTable?
[quoted text clipped - 12 lines]
> but it works only if I click on the  lines of the table and it doesn't if
> I click in the middle of a cell.

select * from double_click where is_middle_of_cell = true;

Or you could just try c.l.j.gui instead :)

Signature

Kind regards,
Christophe Vanfleteren



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.