I want to use mouse listeners and key listeners in A Jpanel because i use it to edit a JPG. To allow listeners I use:
jWriteOnImage extends JPanel. The strange thing is that in a JFrame everything works perfectly, but the listeners don't work if the JPanel is in a JDialog.
Thanks for your help,
Alejandro Barrero
Your help will be greatly appreciated,
Alejandro Barrero
Thank you very much Craig, but I don't think you are addressing my problem; I am afraid I did not explained clearly. What I am doing is adding listeners to the JPanel to react to events when the user clicks on the panel to select a position to type and when the user types a key to enter data into the JPane. My code works when the JPanel is in a JFrame (the user can enter text in different places and then can save the image with the text entries); the mouse listeners and key listeners do the work. My problem is that if I change the JFrame to a JDialog my code doesn't work.
Your help will be greatly appreciated,
Alejandro Barrero
So it seems that your problem only occurs in specified situations, situations that we won't be able to reproduce without seeing your code I'll bet. My recommendation goes back to Darryl's: please post an SSCCE. You'll find a helpful link on how to create this creature and why it's important in Darryl's post again.
For instance, this is my SSCCE of your problem. Note that it's a bit too long for a true SSCCE, sorry. Also, to change the JTextField to a JLabel, you must press enter after entering text:
If you run mine, you'll see that it works the same for a JFrame as for a JDialog. Unfortunately I can't run yours as you are missing the TextDialog class code.