About Internal Frames

Hi everyone in the forum,

I have a question, i am using some internal frames in an app and i need to open one internal frame just cliking in a button in another one, and i have no clue how to do it. All the internal frames are created from a father interface. So there is like a father class (called mInterface) which creates the different children, e.g. GraphicalView, InformationView, ConfigurationView, TableView ...

The goal i am looking for, is to let for exampe the possibility to open the information form the configuration but i do not know how to implement it.

I do not think it is neccesary but, in case of it, I post a part of the creation of the internal frame code.

privatevoid menuTable(JMenuBar bar ){

JMenu addMenu =new JMenu("Tables Information " );// create Add menu

JMenuItem openConfiguration =new JMenuItem("Open Tables Window" );

addMenu.add( openConfiguration );// add new frame item to Add menu

bar.add( addMenu );// add Add menu to menu bar

setJMenuBar( bar );// set menu bar for this application

theDesktop =new JDesktopPane();// create desktop pane

add( theDesktop );// add desktop pane to frame

// set up listener for newFrame menu item

openConfiguration.addActionListener(

new ActionListener()// anonymous inner class

{

// display new internal window

publicvoid actionPerformed( ActionEvent event )

{

// create internal frame

if (frameTables ==null){

frameTables =new JInternalFrame("Information Interface", true, true, true,true );

JPanel panel =new JPanel(new BorderLayout());

panel.add( cTables.openTablesInfo(), BorderLayout.CENTER);

frameTables.add( panel, BorderLayout.CENTER );// add panel

frameTables.pack();// set internal frame to size of contents

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

frameTables.setSize(screenSize.width / 3 * 2,screenSize.height / 4 * 3 );

theDesktop.add( frameTables );// attach internal frame

frameTables.setVisible(true );// show internal frame

frameTables.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

//changed = false;

}

frameTables.setVisible(true);

}// end method actionPerformed

}// end anonymous inner class

);// end call to addActionListener

}

[3786 byte] By [patucosa] at [2007-10-3 4:51:12]
# 1
Always start by reading the Swing tutorial......[url http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html]How to Use Internal Frames[/url]
camickra at 2007-7-14 22:55:52 > top of Java-index,Desktop,Core GUI APIs...
# 2

I already did it, the question is not like the examples which appear at the end of the tutorial. The nearest one to the problem i have is the internal frame listener but not even what i was wondering. In the example is the internal frame the one which creates the other one.

What i am trying to do is that an internal frame call another internal frame, but all the internal frames are created by a main class which contains the desktop. I pasted some code as an example, so what i am trying to show is that i have a main window with several menus, each one creates just one internal frame (i play with the internal frame methods toFront or hide). There is an information internal frame which should call the configuration internal frame. as you can imagine this option, to access directly to the configuration internal frame is also a menu. Instead of duplicating classes or code i was looking for some method to say the main class to open (setVisible) the frame.

I used listener to another class to call the main class, but it is causing me errors and i think it should be anoter more "elegant" solution :).

I hope it makes clearer my problem. if anyone has any idea it will be more than welcome.

patucosa at 2007-7-14 22:55:52 > top of Java-index,Desktop,Core GUI APIs...
# 3
Hidoes anyone know how the internal frame can open another internal frame by calling the desktop where they are contained?Thankx
patucosa at 2007-7-14 22:55:52 > top of Java-index,Desktop,Core GUI APIs...