How to pass class instance to class in separate package
<p>I recently made a package for handling GUI loading in my project. The problem is I’m trying to keep it dynamic and reusable without adding required classes such as MySQL.  However, for some of my GUI, I need MySQL access. I have a classes called <code>Core_MySQL</code> with the basics of what I need, but I need to be able to access it from the GUI (in separate package).  Is it possible to load my GUI and have it call my parent class to get access to this information?  </p>

<p>I will try to explain below.</p>

<pre><code>Main Package (com.addramyr.Core)
    Core_GUI
    Core_MySQL

GUI Package (com.addramyr.GUI)
    MainMenu

Outside Class (com.addramyr.Resources.GUICore)
    GUICore
</code></pre>

<p>When <code>Core_GUI</code> loads, it calls a file from <code>GUI_Core</code> that uses <code>JSPF</code> to load the required GUI.  However, I need to pass the current instance of <code>Core_MySQL</code> that’s running in <code>CoreGUI</code> down to <code>MainMenu</code>.</p>

<pre><code>Loading: Core_GUI (has instance of MySQL) -&gt; GUICore -&gt; MainMenu
</code></pre>

<p>In my <code>Core_GUI</code>, I’ve tried adding the following to parse MySQL down with no success.</p>

<pre><code>cGUI.LoadParent(sql);
</code></pre>

<p>Any advice with this would be greatly appreciated.</p>

<p>Here is some of the code...</p>

<pre><code>public class Core_GUI {
    protected GUICore cGUI;
    public Core_MySQL sql = new Core_MySQL();

    protected Core_GUI(Core parent) {
        cGUI = new GUICore(true);
        cGUI.LoadParent(sql); // This section passes this class to Core_MySQL
        cGUI.setGUI("MainMenu"); // Select MainMenu class containing GUI.
        cGUI.Load(); // Load MainMenu GUI.
    }
    ...
}

public class GUICore {
    ...
    public void LoadParent(Class&lt;?&gt; cParent) {
        GUIParent = cParent;
    }

    public void Load() {
        pGUI.LoadGUI(GUIParent); // when the GUI loads pass the parent from Core_GUI to MainMenu
    }
}

public class MainMenu extends JFrame implements GUIRequirements, ActionListener {
    private Object myParent;

    public String LoadGUI(Object oParent) {
        myParent = oParent;
        myParent.BotConnect(); // The method BotConnect() is undefined for the type Object
    }
}
</code></pre>

<p>Want to point out one more time this is using the JSPF framework.</p>

<p>BotConnect is a method i have in my <code>Core_MySQL</code> Class</p>
