Java: Call JInternalFrame from another JInternalFrame

I am developing a desktop Application in Java Swing. I am facing a problem showing a JInternalFrame from Another JInternal Frame.

I have 3 Frames The main frame, in Which i put jdesktopPane is (frmMain) and 2 JInternalFrames (f1 and f2)

I have menus in frmMain from where i can call and display the 2 JInternalFrames easily but the problem is How to call f1 from clicking a button on f2.

answer:

First create f1 frame object on f2 button action

F1 f1 = new F1();

Then create a JDesktopPane object like this

JDesktopPane desktopPane = getDesktopPane(); desktopPane.add(f1);//add f1 to desktop pane f1.setVisible(true);// set the f1 frame visible

Finally if needed dispose the current frame

this.dispose();

sumber:
http://stackoverflow.com/questions/19086934/java-call-jinternalframe-fron-another-jinternalframe

Tidak ada komentar:

Diberdayakan oleh Blogger.