i updated the code because many people doesn't understand so write a simple representation for that. here is the problem whenever i clicked the button it open a new frame but i dont want this it does't open a new frame it remain open the same frame.
code for main frame :
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class JavaProject2_27 {
    private JFrame frame;
    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    JavaProject2_27 window = new JavaProject2_27();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * Create the application.
     */
    public JavaProject2_27() {
        initialize();
    }
    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);
        JButton btnClicked = new JButton("Clicked");
        btnClicked.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                JavaProject2_28 obj=new JavaProject2_28();
                obj.getJavaProject2_28();
            }
        });
        btnClicked.setBounds(150, 99, 89, 23);
        frame.getContentPane().add(btnClicked);
    }
}
code for the second frame :
import java.awt.EventQueue;
import javax.swing.JFrame;
public class JavaProject2_28 {
    private JFrame frame;
    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    JavaProject2_28 window = new JavaProject2_28();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * Create the application.
     */
    public JavaProject2_28() {
        initialize();
    }
    public void getJavaProject2_28()
    {
        frame.setVisible(true);
    }
    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
 
    