Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

internal frame error  RSS feed

 
Puneet N Vyas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to lunch an internal frame from an menu item,but when i lunch it from main frame,the main frame's content becomes invisble,can any one tell
me,how can i make main frame's content's visble even after internal frame has been lunched from main frame,here is the code i wrote

[import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class internalframe extends JFrame
{
JMenuBar bar;
JMenu m1,m2,m3,m4;


public internalframe()
{


super("internal frame demo");

bar=new JMenuBar();
m1=new JMenu("launch inernal frame");
JMenuItem ie=new JMenuItem("open frame");
Container c1=getContentPane();

//c1.add(bar);
bar.add(m1);
m1.add(ie);
setJMenuBar(bar);

//anonymos classes
ie.addActionListener(new ActionListener( ) {
public void actionPerformed(ActionEvent e)
{

JDesktopPane d1=new JDesktopPane();

JInternalFrame i1=new JInternalFrame("my experiments",true,true,true,true);
d1.add(i1);
//i1.add(b1);
setContentPane(d1);
i1.setVisible(true);
i1.setBounds(300,200,400,100);

i1.setLayout(new FlowLayout());

}
});


}
public static void main(String args[])
{
internalframe in=new internalframe();
in.setVisible(true);
in.setBounds(300,200,200,300);
in.setSize(100,300);
in.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
in.setLayout(new FlowLayout());


}

}] [/CODE]
 
Steven Wall
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed you are creating the JDesktopPane in the listener. I would think you would want to create it and add it to the JFrame's content pane when initializing the frame. Maybe that would help.
 
Puneet N Vyas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any body modify the code to display the main frame's components after the internalframe is lunched
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!