I have a JDesktopPane that opens and with a login it will add an InternalFrame with the InternalFrame 'innerclass'.

The problem is that when I want to add another InnerFrame to the desktop I can't call the inner class to add an Internal frame because it wants me to login again first.

Is there some way to add an InternalFraame from another class once the desktop is running alrady?
thanks

yup, if you code it correctly that should be possible.

That's all that can be said without knowing what convoluted code you produced to generate the behaviour you describe.

lol. that is exactly the case. I will try to control the behavior of logging in better to get to the next error. thanks

I have never been able to call a class after it has been

initialized.
I would like to add a InnerFrame to my JDesktopPane if possible.

When I run the program it logs in if

isLoggedIn 

==false

with an actionPerformed from a combobox I need to skip creating

a new JDesktop and login but add a internal frame only.
How is this done?

I tried a new approach but I still have no clue.

public class ViewFrame {
     
   
    public ViewFrame() throws ProfileException, LoginException, FileNotFoundException,
            IOException, model.err.LoginException {
    }

    public void createViewFrame(String ln, JScrollPane scrollpane) throws ProfileException, LoginException,FileNotFoundException,IOException, model.err.LoginException, SQLException,ClassNotFoundException, InstantiationException,
IllegalAccessException {
        System.out.println("in createViewFrame()");
        Class thisClass =Class.forName("view.SchoolJDesktopPane");        
        SchoolJDesktopPane sdjp=(SchoolJDesktopPane)thisClass.newInstance();         
        sdjp.setIsLoggedIn(true);//if true no login();
        sdjp.createViewFrame(ln, scrollpane);
    }
}

I keep hearing that it can be done but is there a link or an example that describes how to call my Innerclass of my JDesktopPane after it is already running the JDesktop?

you have an instance of a class, you can call methods on that instance if you have a reference to it.
If you don't maintain a reference, you should start figuring out how to do that (or how to get the JDesktop to give you one, no doubt it has functionality to do just that).

you have an instance of a class, you can call methods on that instance if you have a reference to it.
If you don't maintain a reference, you should start figuring out how to do that (or how to get the JDesktop to give you one, no doubt it has functionality to do just that).

It Is encouraging to learn of using a reference to a class. Although I am not sure if I actually do this yet. It seams that I need to build the desktop and re-code the login 'panel' to be called as a actionPerformed() then it may not emerge unwanted later. Then I can see if calling a method using an instance is something I can work in.
Thanks

I have never been able to call a class after it has been initialized.
I would like to add a InnerFrame to my JDesktopPane 'SchoolJDesktopPane.java'if possible.

with an actionPerformed from a combobox I need to add a internal frame .
How is this done?

I tried everything.I have no clue.

package view.content.panels.guide;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import model.ModelUtils;
import model.dao.ConnectAdminDAO;
import model.err.LoginException;
import model.err.ProfileException;
import model.utils.CachingResultSetTableModel;
import model.utils.ResultSetTableModel;
import model.utils.ScrollingResultSetTableModel;
import view.DataViewFrame;
import view.ViewUtils;

public class AdminPanel extends JPanel implements ActionListener {
    public ResultSetTableModel model;
    public JButton nextButton;
    public JButton previousButton;
    public ResultSet rs;    
    public Connection conn;
    public Statement stmt;   
    public static boolean SCROLLABLE = false;   
    public ConnectAdminDAO cad;
    public String thisUser;
    public boolean profile;
    public boolean student;
    public boolean instructor;
    public boolean admin;
    public boolean payee;    
    public String[] record;
    public int recordCount;
    public JTable table;
    public String RES="selectAdmin";
    
    private String tableName;

    public AdminPanel() throws FileNotFoundException, IOException, SQLException {
        initComponents();
        setThisUser(ViewUtils.getThisUser());
        //setProfile(ViewUtils.isAdmin());//more than one profile?
        cad = new ConnectAdminDAO();
        conn = (Connection) cad.allTables();
        DatabaseMetaData meta = conn.getMetaData();
        if (meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) {
            SCROLLABLE = true;
            System.out.println("in personalDataTable: Supports TYPE_SCROLL_INSENSITIVE");
        } else {
            SCROLLABLE = false;
            System.out.println("in personalDataTable; No support for Supports             TYPE_SCROLL_INSENSITIVE");
        }
        if (SCROLLABLE) {            
            String[] types = {"TABLE"};
            stmt = (Statement) conn.createStatement(
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            DatabaseMetaData md = conn.getMetaData();
           // mrs = md.getTables(null, null, null,new String[]{"TABLE"});
            ResultSet mrs = md.getTables(null, null, null, types);
            while (mrs.next()) {
                tableNamesCB.addItem(mrs.getString(3).trim());
                System.out.println(mrs.getString(3).trim());
            }
            mrs.close();
        } 
        tableNamesCB.addActionListener(this);
    }

    public void actionPerformed(ActionEvent evt) {
        
        if (evt.getSource() == tableNamesCB) {  // show the selected table from the combo box
             
            if (displayScrollPane != null) {
                this.doLayout();
                displayPanel.remove(displayScrollPane);
                
            }
            try {
               tableName = (String) tableNamesCB.getSelectedItem();
                if (rs != null) {
                    rs.close();
                }
               String str=RES.concat(tableName);
               System.out.println("select statement : "+str);                            
               stmt =conn.createStatement(
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
               String query=(ModelUtils.getXMLResource(str));
                //String query = "SELECT * FROM " + tableName;
                rs = stmt.executeQuery(query);
                if (SCROLLABLE) {
                    model = new ScrollingResultSetTableModel(rs);
                } else {
                    model = new CachingResultSetTableModel(rs);
                }
                table = new JTable(model);               
                displayScrollPane  = new JScrollPane(table);
                displayScrollPane.setAutoscrolls(true);
                displayScrollPane.setViewportView(table);
               [b] DataViewFrame dvf =new DataViewFrame(displayScrollPane,tableName);[/b]
               
                
            } catch (ProfileException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (LoginException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AdminPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException e) {
                System.out.println("Error " + e);
            }
        }
    }

    public boolean isProfile() {
        return profile;


    }

    public void setProfile(boolean profile) {
        this.profile = profile;


    }

    public String getThisUser() {
        return thisUser;


    }

    public void setThisUser(String thisUser) {
        this.thisUser = thisUser;


    }

   

    
    
    

    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

    }
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import model.err.LoginException;
import model.err.ProfileException;
import view.SchoolJDesktopPane.InternalFrame;

/**
 *
 * @author depot
 */
public class DataViewFrame extends SchoolJDesktopPane{ 
   
    public DataViewFrame(JScrollPane scrollPane,String ln) throws ProfileException, LoginException, FileNotFoundException, IOException, SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
       /*
        Class thisClass=(Class) Class.forName("view.SchoolJDesktopPane");
        jdp=(SchoolJDesktopPane) thisClass.newInstance();
       // jdp.createDataFrame(scrollPane, ln);
        * 
        */
        
        setGuideName(ln);
         JPanel contentPane = new JPanel();
        contentPane.add(scrollPane);
        //Class x=(Class) Class.forName("view.SchoolJDesktopPane.InternalFrame");
       // frame= (InternalFrame) x.newInstance();
        frame=new InternalFrame();
        frame.add(contentPane);        
        jdp.add(frame);
    }

   
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.