Olá amigos estou com dúvida de como fazer com que essa minha Classe Login, através do botão btCadastrar chame uma outra classe chamada teladecadastro, alguém pode me ajudar???
import java.awt.Font;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.JRootPane;
import javax.swing.JTextField;
import javax.swing.JOptionPane;
public class Login extends JFrame implements ActionListener{
JLabel id, pwd, titulo;
JButton btEntrar, btCadastro, btSair;
JTextField tfID;
JPasswordField tfPWD;
Login(){
setTitle("Login");
setSize(290, 195);
setLocationRelativeTo(null);
setResizable(false);
getContentPane().setLayout(null);
titulo = new JLabel ("Dados do Usuário:");
titulo.setFont(new Font("SansSerif", Font.BOLD, 15));
id = new JLabel("Usuário:");
pwd = new JLabel("Senha:");
btEntrar = new JButton("Entrar");
btCadastro = new JButton("Cadastro");
btSair = new JButton("Sair");
tfID = new JTextField();
tfPWD = new JPasswordField(12);
tfPWD.setEchoChar('*');
btEntrar.addActionListener(this);
btCadastro.addActionListener(this);
btSair.addActionListener(this);
getContentPane().add(titulo);
getContentPane().add(tfID);
getContentPane().add(tfPWD);
getContentPane().add(id);
getContentPane().add(pwd);
getContentPane().add(btEntrar);
getContentPane().add(btCadastro);
getContentPane().add(btSair);
getRootPane().setDefaultButton(btEntrar);
titulo.setBounds(85, -15, 140, 90);
id.setBounds (25, 50, 70, 25);
tfID.setBounds (85, 50, 180, 22);
pwd.setBounds (24, 80, 70, 25);
tfPWD.setBounds (85, 80, 180, 22);
btEntrar.setBounds(20, 110, 70, 25);
btCadastro.setBounds(103, 110, 90, 25);
btSair.setBounds(205, 110, 60, 25);
}
public static void main(String[] args){
JFrame janela = new Login();
janela.setVisible(true);
janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == btEntrar){
if(tfID.getText().equals("mcmarcelosp") && new String(tfPWD.getPassword()).equals("mc1209")){
setVisible(true);
JOptionPane.showMessageDialog(null, "Acesso Permitido");
tfID.setText("");
tfPWD.setText("");
setVisible(false);
}
else{
JOptionPane.showMessageDialog(null, "Senha ou Usuário Incorreto.", "Acesso Negado", 0);
tfID.setText("");
tfPWD.setText("");
}
}
if (e.getSource() == btCadastro){
tfID.setText("");
tfPWD.setText("");
}
if (e.getSource()== btSair){
setVisible(false);
}
}