How can I close a JTabbedPane with an JInternalFrame included when I click a button inside this form?
My project has 3 JForms, 1 TabbedPane, 1 JInternalFrame and 1 Main window (to register data). To create my JTabbedPanes I use the method addTab() and from that form I have the button to close which calls another window (Main registry), I used the dispose() and setVisible(false) methods but they don't do anything.
An example (there are 3 clases -Administrador, -MenuPrincipal, -ventanaRegistro) :
First Class a JFrame and on top a JTabbedPane (this is where I create my tabs)
public class MenuPrincipal extends javax.swing.JFrame 
{
    Administrador ventanaAdministrador = new Administrador();
    void showTabs()
    {
        JTabbedPane.addTab("Administrador", ventanaAdministrador);
    }
    public MenuPrincipal() 
    {
        initComponents();
        showTabs();
    }
}
Second Class a JInternalFrame with a single button
public class Administrador extends javax.swing.JInternalFrame 
{
    void showAdminWindow()
    {
        ventanaRegistro ventanaRegistro = new ventanaRegistro();
        ventanaRegistro.setVisible(true); 
    }
    void closeThisWindow()
    {
        this.dispose();
    }
    public Administrador() 
    {
        initComponents();
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)    {                                         
        showAdminWindow();
        closeThisWindow();
    }
}
Third Class a simple JFrame. This is just code to register data.
The real problem is that my method closeThisWindow() doesn't close the second Jtabbed window, and I want to make it that when I click a button (which is on the JTabbedPane) make the third class visible and the Second Class invisible/Close it.      
                        
See if the following code does what you expect. If it doesn't please elaborate so I can improve my answer.
And: