you should be using events. your main class could listen for an event, if the button in the window is pressed. e.g.
public static void main(String[] args) {
Window w = new Window();
w.getBtnNewButton().addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(w.getPin() + Arrays.toString(w.getPassword()) + '1');
}
});
}
in this case you have to make a public getter for the button, so you can access it from the main class.