In My Eclipse Project, I have a
Text custom_text = new Text(....);
Now I add a listener –
custom_text.addKeyListener(new
KeyListener(){@Override public void keyPressed(KeyEvent event) {
}
@Override public void
keyReleased(KeyEvent event) {
System.err.println(“event
“+event.getSource()));} });
Anyhow, I am not getting the source name,despite I am getting the output as Text {}.
Well I want to get the source name ie custom_text .
How to get the output in a listener as
custom_text
IMHO you can not the name of the variable, holding the reference to your textfield. It is also not really of any use to know the name of the variable, since you can have many referencing variables.
With .getSource() you get a full reference to the widget itself, so you can deal with it in any way.