Skip to main content

MouseAdapter not recognized

3 replies [Last post]
Joined: 2005-08-17


I need to detect double click on a table. Code fragment to capture mouse event is given below:

import java.awt.event.*;

Table {
var tableListener: MyTableListener = new MyTableListener()
gridColor: Color

mouseListener: tableListener


public class MyTableListener extends MouseAdapter
operation mouseClicked( e: MouseEvent);

operation MyTableListener.mouseClicked( e: MouseEvent)
System.out.println("mouse clicked");

The compiler gives following error:
incompatible types: expected java.awt.event.MouseListener, found MyTableListener in mouseListener: tableListener

What seems to be the problem? MyTableListener is a MouseListener as it extends MouseAdapter.
Any help will be appreciated.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-08-17
Joined: 2005-08-17

Thanks. That works. I had to use operation instead of function.

On mouse click I need to get data in the selected row.
Could you plese show the code fragment to do that?
Thanks a lot.

~ Tushar

Joined: 2007-07-12

Try to use [b]onMouseClicked[/b] attribute. For example:

import javafx.ui.*;
import java.lang.System;

var N = 4;

Frame {
title: "JavaFX Table"
width: 300
height: 150

content: Table {
columns: [
TableColumn { text: "number" },
TableColumn { text: "square" },
TableColumn { text: "cube" }

cells: for( n in [1..N]) [
TableCell{ text: "{n}" },
TableCell{ text: "{n*n}" },
TableCell{ text: "{n*n*n}" }

onMouseClicked: function(e: MouseEvent){
if(e.clickCount == 2){
System.out.println("Double click!");

visible: true

The code is written on compiler version of JavaFX Script language.