• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing focus from one panel to another

 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please let me know if it possible to change mouse event from one component in panel1 one to another component in panel2.

I am currently using JLabel as hyperlink in one panel and OK button in another panel. When i click "OK" button directly, it works. But when i click on hyperlink(JLabel), and then click on "OK" button its not working.


Thanks In advance,
Seema
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my mind, it mostly depends on the code in the mouse listener that you've added to your jlabel.
 
Seema Sharma
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here my Jlabel is in paint method. Wil mouse listeners work for paint method.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Seema Sharma:
Here my Jlabel is in paint method. Wil mouse listeners work for paint method.

This may be a bad idea. Your paint method (or for Swing, paintComponent method) should do nothing but paint. It shouldn't be involved in program logic, GUI building (other than pure drawing) or user interaction. Again, it's hard to tell what's going on in your program with the amount of information so far shared, but it sounds as if you need to delve into the Sun Java Swing tutorial to review the basics of Swing. I know that I go through it several times a month because invariably I find something that shows my assumptions to be wrong. Best of luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!