Opening a new window on a button click in java

I’m just starting with using interfaces in java, I’m okay with having just one window and that doing what i need. But i now want to link two windows together e.g.

window 1 opens.
user chooses button1 (enter data).
window 2 opens so user can enter the data.

Code for window 1:

import javax.swing.*;

public class Task_3 extends JFrame {
    private Button btn1, btn2, btn3;
    public Task_3(){

      setLayout(new FlowLayout());

      btn1 = new Button("Enter data");
      add(btn1);
      btn2 = new Button("Check who is going");
      add(btn2);
      btn3 = new Button("View costs");
      add(btn3);

      setTitle("Event Costs");
      setSize(280, 150);
      setVisible(true);

      // close the window
      addWindowListener(new WindowAdapter()
      {
      public void windowClosing(WindowEvent e)
      {
         dispose();
         System.exit(0); //calling the method is a must
      }
      });

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

Code for window 2:

import java.awt.*;
import java.awt.event.*;

public class Task1GUI extends Frame implements ActionListener {
    private Label lblInput;
    private Label lblOutput;
    private TextField tfInput;
    private TextField tfOutput;
    private int sum = 0;

    public Task1GUI(){
        setLayout( new FlowLayout());

        lblInput = new Label("Enter number of students: ");
        add(lblInput);

        tfInput = new TextField(5);
        add(tfInput);

        tfInput.addActionListener(this);

        lblOutput = new Label("The cost per student is: ");
        add(lblOutput);

        tfOutput = new TextField(20);
        tfOutput.setEditable(false);
        add(tfOutput);

        setTitle("Task1GUI");
        setSize(350, 120);
        setVisible(true);

        addWindowListener(new WindowAdapter()
      {
      public void windowClosing(WindowEvent e)
      {
         dispose();
         System.exit(0); //calling the method is a must
      }
      });
    }
    public static void main(String[] args){

        new Task1GUI();
    }

    @Override
    public void actionPerformed(ActionEvent evt){
        int numOfStudents = Integer.parseInt(tfInput.getText());
        int coachCost = 550;
        int entrycost = 30;
        int totalcost;
        int numFree;
        int Discount;
        int costPerPerson;
        if(numOfStudents<45){
        totalcost = coachCost+(numOfStudents*30);
        numFree = numOfStudents/10;
        Discount = numFree*30;
        costPerPerson = (totalcost-Discount)/numOfStudents;
        tfInput.setText("");
        tfOutput.setText(costPerPerson+"");
    }
    else{
        tfOutput.setText("Too mant students entered");
    }
    }
}

Basically I would like some help with linking these two programs together so that the user can open the first window choose which action they would like to do.

I have only been working with the console up until very recently so if my code is not perfect I apologise but I would really appreciate any help with this.

Thanks