Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How use the classes Observer & Observable ?  RSS feed

 
myyyy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I try to create an example which uses the classes Observable and Observer. Can you
give me a good example (which works ;-) ) ?
How Can we program this example ?
a window (JFrame) :
-------------------------------
| Language | Tools | | <- JMenu
-------------------------- |
| | French | | <- JMenuItem
| ------------- |
| | English | | <- JMenuItem
| ------------- |
| |
-------------------------------

What I want to do is : when we click the JMenuItem "French", the title "Tools"
has to become "Outils", and vice-versa.

Can you give me an example of code which works ?
My goal is to use Observer & Observable (for
big projects !).
Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"myyyy" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

I'm sure you can find explainations of how to use the Observer/Observable classes all over the place... (here's a short tutorial here...) However, for the particular problem you are describing, it would be better to use the Internationalization API, as it is already a solution to your problem, and will allow your application to easily be translated into more languages.

Thanks! and welcome to the JavaRanch!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!