• 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
consider the modified code,this code just lunch the internal menu upon clicking a menu item,but when internalframe gets opened the main frame get's hidden,can any one tell,how to make it visble when either we mininmize the internal frame or close the internal frame..


{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());

}

}
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags round quoted code; they make it easier to read.
Please use copy-and-paste when quoting code; that will avoid silly mistakes like "{import".

You appear to be creating a new internal frame every time the MenuItem is clicked. Not sure what you intend, but creating that many frames looks very suspect. It seemed to work when I tried it however.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!