Question: I was wondering on how I would create a method that opens up a new jframe in a separate window that will allow me to search through information. At the moment I have a button that says click me, however, I want to put in an event whereby once it is clicked, it will open up a new window that a user can input a string to search through information. Should I create a new class for the Jframe? any tips and code would be greatly appreciated. Thanks!

Answer: 
It depends on the feature list that you will have in your second window, If feature list is quite expanded then its better to have it a separate class, also JFrame is not required even JDialog will do.

Sample code as to show how to open a JDialog on click of a button is below:

```
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class TestFrameOnFrame extends JFrame implements ActionListener{

    public TestFrameOnFrame(){
        JButton button = new JButton("Show New Frame");
        button.addActionListener(this);
        this.add(button);
        this.pack();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        JDialog dialog = new JDialog(this);
        dialog.setTitle("Search Dialog");
        dialog.add(new JLabel("Just a test"));
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setVisible(true);
    }

    public static void main(String[] args) {
        new TestFrameOnFrame();
    }
}

```
Depending on the complexity of this '2nd frame', you could use an inner class, or make it separate. Either way, just have the event listener on your button fire up an instance of this new class, which either is or creates a new Jframe and sets it to visible.