When i clicked on JMenuitem ..it opens a new window ..but when i close this window the parent window also closes...

is there any method to resolve ..i don't want to close the parent window only the new window..

Post a small working program to show what you are talking about.

import javax.swing.*;
import java.awt.*;

import com.sun.awt.AWTUtilities;

import java.awt.Color;
import java.awt.Point;
import java.awt.Shape;
import java.awt.event.*;
import java.awt.geom.RoundRectangle2D;

public class window extends JFrame{

    public static void main(String args[])

    JFrame window=new JFrame();


    //Container c= window.getContentPane();

    JMenuBar menubar=new JMenuBar();

    JMenu help=new JMenu("help");
    JMenuItem helpcontent=new JMenuItem("helpcontent");
helpcontent.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
        JTextArea ta = new JTextArea(10, 35);
        JScrollPane jscrollpane = new JScrollPane(ta);

          JFrame f = new JFrame("JScrollPane");
          f.setLocation(new Point(700, 182));

          f.setSize(250, 300);



This is the small working program...when you click on helpcontent .it opens a window and when you close it closes the main(parent ) window also ....I do not want the parent window to close ..i want only to close the opening window..

If you can help it would be great....


Why do I want your jar file?

just to run it...by double click my dude...by this way ..you can run it ...my code ..you will be able to see the example by double click ...

Did you look at the code I posted earlier? Read the API doc for that method and its args.


but it closes both window ...I don't want that to close ..it also closes parent window...only the second window needs to be closed not the parent one ..look at the code above ...i did that

Did you read the API doc for the method call that I posted above?
Please do. Then come back if you have any questions.
Be sure to copy and paste here the text of the doc you question.




Be a part of the DaniWeb community

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