I have a JFrame called MainFrame where almost all of the components for my application are found. It has a JTabbedPane and lots of JPanels to group components. Now I have to build some custom cell editors or buttons that affect a lot of components on my JFrame and some helper classes, that need information from many components in my JFrame. What I've done so far is to pass these components/values of components to the constructor of helper classes or to custom editors which sometimes a lot of components. I feel like there is something wrong with it. Like I'm passing a lot of values from the constructor. I'm thinking of just passing the MainFrame and get its components. How can I get these components from the MainFrame and the specific components that I need? Or suggest a better approach.
You can create a HashMap gui and put any component you want to that map. Then get the components u need like gui.get("myButtonID"); Putting the component's name in Map may be good idea.
You can get all your frame components by:
You can get sub-components of the main containers by:
// Assuming component is a container ((Container)component).getComponents();
You can get component name by: