Quick question about right way to add a custom jtoolbar
Hy guys a quick question:
I have a jframe where i want to add a custom jtoolbar, a jlist in a scrollable pane.
I made the custom jtoolbar because i want all buttons to be added in its constructor and not in frame's code(because lot of code, toolbar has its own file, jlist its own file)
The problem is that button's actions make changes to my jList (which is not accessible in toolbar's class file where buttons actions are implemented).
What's the correct way to interact with the JList?
1. Pass it to the Jtoolbar in toolbar's constructor?
2. Get it from the frame(searching for it in frame's components)?
3. Not implementing the actions in toolbar's class, but in main frame and set actions to the buttons in main frame( i won't like this solution but if this is correct way, i'll do it like that)