Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help in design  RSS feed

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I'm building an application that has a Jtable for drawing, jpanel with Jbuttons and so on. I have registered a mouselistener to the Jtable so I know the cells that are selected / or if the user click on an already defined boc in the Jtable.

I need to notify the JPanel in some way. There are in diffrent classes and so far I have always used static classes to referens them. But isn't there a better way doing this?

How can I notify classes and let them be aware of other classes?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mathias Nilsson:
... How can I notify classes and let them be aware of other classes?

Hmmm... It's difficult to recommend a particular approach without more information, but it sounds like you might want to consider the Observer pattern. Check the API documentation for java.util.Observable, and let us know if this is what you're looking for.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

I think that it exactly what I am looking for.
I will dig into this. Many Thanks!

// Mathias
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!