This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bilateral Interaction Between JComponents  RSS feed

 
Tim Jung
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gentlemen:

currently I am implementing a visualization which is becoming more complex. Consequently I want to separate the GUI-class to get a better overview by using smaller classes.

In my GUI I will have such a structure:
A: JFRame with 3 Components
- TreeMap with VisualItems
- Interaction Controls
- a JTextArea

If the mouse is over a visualItem in the JTextArea the name of the node shall be displayed. Which possibilities are there for the implementation?

1. I know that it can be done by using inner classes, as the inner classes have acess to the parameters of the outer class.

2. Are there any methods in JAVA that an element e.g. the TreeMap can identify the own-top-level container (here JFrame).

3. How can an MouseListener e.g. here in the class TreeMap trigger a change in a third class (e.g. JText Area)?

4. Is there no other possibility as to implment the Interaction Controls and JTextArea as inner classes of the TreeMap?

With best regards and thanks for all the help
Tim
 
Andre Uhres
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We may try to approach the MVC design and create a controller class containing the references to the view classes and the implementation of all Listeners.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!