Galera bom dia,
Gostaria de saber em que trecho do codigo abaixo devo fazer a conexao com Mysql.
package formulario;
import javax.swing.<em>;
import java.awt.</em>;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.event.*;
import javax.swing.text.MaskFormatter;
import java.text.ParseException;
public class locadora extends JFrame implements ActionListener
{
JLabel lb_titulo;
JLabel lb_nome;
JLabel lb_rg;
JLabel lb_cidade;
JLabel lb_sexo;
JTextField tf_nome;
JTextField tf_rg;
JTextField tf_cidade;
JRadioButton jrb_masc, jrb_fem;
ButtonGroup grupo_sexo;
JPanel panel_sexo;
JButton bt_salvar, bt_sair, bt_novo;
JFormattedTextField format_rg;
MaskFormatter mascara_rg;
public locadora()
{
setTitle("FICHA DE CADASTRO");
setLocation(380, 30);
setSize(380, 400);
getContentPane().setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
getContentPane().setBackground(Color.DARK_GRAY);
lb_titulo = new JLabel("CADASTRAR CLIENTE");
lb_nome = new JLabel("NOME :");
lb_rg = new JLabel("RG :");
lb_cidade = new JLabel("CIDADE :");
lb_sexo = new JLabel("SEXO :");
tf_nome = new JTextField("",50);
tf_rg = new JTextField("",50);
tf_rg = new JFormattedTextField(mascara_rg);
tf_cidade = new JTextField("",50);
jrb_masc = new JRadioButton("Masculino");
jrb_fem = new JRadioButton("Feminino");
grupo_sexo = new ButtonGroup();
grupo_sexo .add(jrb_masc);
grupo_sexo .add(jrb_fem);
panel_sexo = new JPanel();
panel_sexo.setLayout(new GridLayout(1,2));
panel_sexo.add(jrb_masc);
panel_sexo.add(jrb_fem);
bt_salvar = new JButton("SALVAR");
bt_salvar .setMnemonic(KeyEvent.VK_S);
bt_sair = new JButton("SAIR");
bt_sair .setMnemonic(KeyEvent.VK_S);
bt_novo = new JButton("NOVO CADASTRO");
bt_novo .setMnemonic(KeyEvent.VK_N);
lb_titulo .setBounds (120, 20, 200, 40);
lb_nome .setBounds (10, 70, 80, 30);
lb_rg .setBounds (10, 100, 80, 30);
lb_cidade .setBounds (10, 130, 80, 30);
lb_sexo .setBounds (10, 145, 100, 60);
tf_nome .setBounds(70, 75, 200, 20);
tf_rg .setBounds(70, 105, 80, 20);
tf_cidade .setBounds(70, 135, 200, 20);
panel_sexo.setBounds(70, 165, 200, 20);
bt_salvar .setBounds(10, 300, 90, 30);
bt_sair .setBounds(250, 300, 90, 30);
bt_novo .setBounds(105, 300, 140, 30);
try
{
mascara_rg = new MaskFormatter("########-#");
}
catch(ParseException excep)
{
}
format_rg = new JFormattedTextField(mascara_rg);
format_rg .setBounds(70, 105, 80, 20);
lb_titulo .setForeground(Color.RED);
lb_nome .setForeground(Color.BLUE);
lb_rg .setForeground(Color.BLUE);
lb_cidade .setForeground(Color.BLUE);
lb_sexo .setForeground(Color.BLUE);
bt_salvar .setForeground(Color.BLUE);
bt_sair .setForeground(Color.BLUE);
bt_novo .setForeground(Color.BLUE);
getContentPane().add(format_rg );
getContentPane().add(lb_titulo);
getContentPane().add(lb_nome);
getContentPane().add(lb_rg);
getContentPane().add(lb_cidade);
getContentPane().add(lb_sexo);
getContentPane().add(panel_sexo);
getContentPane().add(tf_nome);
getContentPane().add(tf_rg);
getContentPane().add(tf_cidade);
getContentPane().add(bt_salvar);
getContentPane().add(bt_sair);
getContentPane().add(bt_novo);
bt_salvar.addActionListener(this);
bt_sair .addActionListener(this);
bt_novo .addActionListener(this);
}
public static void main(String args[])
{
JFrame obj_locadora = new locadora();
obj_locadora.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == bt_sair)
System.exit(0);
}
}