It doesn't have to do with both listeners being used at the same time. Without the KeyListener, the MouseListeners don't work for me either.
I think the problem is that events are only fired from components that have the focus. I'm not sure if your frame has focus when you're messing with components inside it, or whether it can be focused at all, but a solution would be to put the listeners on a component inside the frame, such as your JTextArea.
first of all: your JFrame class has no main method, so I don't know how you get your
frame on the screen. There's no 'pack' and no 'setVisible(true)' in the constructor.
The mousepanel and the JLabel are nod added, too.
You only add the JTextArea to your frame, effectively adding it to its content pane.
It may be the case that this textarea fully covers your content pane, and since you
did not add the listener to the textarea, your clicks and mouse moves are not handled.
Apart from this, I think that what you did should work, provided there is some part
of the content pane on which you can click.
Also, when the handler is called in case of a mouse move or mouse click, you only
set line 1, so whatever was in line2 and line3 will still be displayed.
I hate signatures!
posted 6 years ago
Thank you; adding the mousepanel has enabled me to use both inputs at the same time