rso1988 8 de nov. de 2011
Allex,
os seus eventos estão funcionando corretamente. Provavelmente você deve ter algum problema nas outras telas. Posta o código delas aqui pra gente ver.
Allexb10 8 de nov. de 2011
Eu tambem achei bem estranho isso. Ja testei as outras telas separadas e funcionam perfeitamente.
Ai esta a classe CadCliente.
package Formularios ;
import java.awt.BorderLayout ;
import java.awt.Dimension ;
import java.awt.GridBagConstraints ;
import java.awt.GridBagLayout ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import javax.swing.BorderFactory ;
import javax.swing.JButton ;
import javax.swing.JFrame ;
import javax.swing.JLabel ;
import javax.swing.JPanel ;
import javax.swing.JTextField ;
@SuppressWarnings ( "serial" )
public class FrmCadCliente extends JPanel {
private String nome = "Nome " ;
private String cpf = "CPF " ;
private String rg = "RG " ;
private String email = "E-mail " ;
private String fone = "Fone " ;
private String uf = "UF " ;
private String bairro = "Bairro " ;
private String cidade = "Cidade " ;
private String rua = "Rua " ;
private String cep = "CEP " ;
private String n = "Nº " ;
public FrmCadCliente () {
JTextField textField = new JTextField ( 10 );
JTextField textField2 = new JTextField ( 30 );
JTextField textField3 = new JTextField ( 20 );
JTextField textField4 = new JTextField ( 10 );
JTextField textField1 = new JTextField ( 10 );
JTextField cuf = new JTextField ( 3 );
JTextField cbairro = new JTextField ( 30 );
JTextField ccidade = new JTextField ( 30 );
JTextField crua = new JTextField ( 30 );
JTextField ccep = new JTextField ( 10 );
JTextField cn = new JTextField ( 3 );
JLabel textFieldLabel = new JLabel ( nome + ": " );
JLabel jcpf = new JLabel ( cpf + ": " );
JLabel jcpf1 = new JLabel ( rg + ": " );
JLabel jcpf2 = new JLabel ( email + ": " );
JLabel jcpf3 = new JLabel ( fone + ": " );
JLabel juf = new JLabel ( uf + ": " );
JLabel jbairro = new JLabel ( bairro + ": " );
JLabel jcidade = new JLabel ( cidade + ": " );
JLabel jrua = new JLabel ( rua + ": " );
JLabel jcep = new JLabel ( cep + ": " );
JLabel jn = new JLabel ( n + ": " );
JPanel textControlsPane = new JPanel ();
GridBagLayout gridbag = new GridBagLayout ();
GridBagConstraints c = new GridBagConstraints ();
JButton jbc = new JButton ( "Cadastrar" );
JButton jbs = new JButton ( "Sair" );
textControlsPane . setLayout ( gridbag );
c . gridwidth = 1 ; // quantidade de espacos verticais
c . gridx = 0 ; // coluna
c . gridy = 0 ; // linha
textControlsPane . add ( textFieldLabel , c );
c . gridwidth = 3 ;
c . gridx = 1 ; // coluna
c . gridy = 0 ; // linha
textControlsPane . add ( textField2 , c );
c . gridwidth = 1 ;
c . gridx = 0 ; // coluna
c . gridy = 1 ; // linha
textControlsPane . add ( jcpf , c );
c . gridx = 1 ; // coluna
c . gridy = 1 ; // linha
c . anchor = GridBagConstraints . WEST ;
textControlsPane . add ( textField , c );
c . gridx = 2 ; // coluna
textControlsPane . add ( jcpf1 , c );
c . gridx = 3 ; // coluna
textControlsPane . add ( textField1 , c );
c . gridx = 0 ; // coluna
c . gridy = 2 ; // linha
textControlsPane . add ( jcpf2 , c );
c . gridwidth = 3 ;
c . gridx = 1 ; // coluna
c . gridy = 2 ; // linha
textControlsPane . add ( textField3 , c );
c . gridwidth = 1 ;
c . gridx = 0 ; // coluna
c . gridy = 3 ; // linha
textControlsPane . add ( jcpf3 , c );
c . gridx = 1 ; // coluna
c . gridy = 3 ; // linha
textControlsPane . add ( textField4 , c );
c . gridwidth = 3 ;
c . gridx = 2 ; // coluna
c . gridy = 3 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( juf , c );
c . gridx = 3 ; // coluna
c . gridy = 3 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( cuf , c );
c . gridwidth = 3 ;
c . gridx = 0 ; // coluna
c . gridy = 4 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( jbairro , c );
c . gridx = 1 ; // coluna
c . gridy = 4 ; // linha
textControlsPane . add ( cbairro , c );
c . gridwidth = 3 ;
c . gridx = 0 ; // coluna
c . gridy = 5 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( jcidade , c );
c . gridx = 1 ; // coluna
c . gridy = 5 ; // linha
textControlsPane . add ( ccidade , c );
c . gridwidth = 3 ;
c . gridx = 0 ; // coluna
c . gridy = 6 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( jrua , c );
c . gridx = 1 ; // coluna
c . gridy = 6 ; // linha
textControlsPane . add ( crua , c );
c . gridwidth = 1 ;
c . gridx = 0 ; // coluna
c . gridy = 7 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( jcep , c );
c . gridx = 1 ; // coluna
c . gridy = 7 ; // linha
textControlsPane . add ( ccep , c );
c . gridwidth = 3 ;
c . gridx = 2 ; // coluna
c . gridy = 7 ; // linha
c . anchor = GridBagConstraints . LINE_START ;
textControlsPane . add ( jn , c );
c . gridx = 3 ; // coluna
c . gridy = 7 ; // linha
textControlsPane . add ( cn , c );
c . anchor = GridBagConstraints . LINE_END ;
c . gridx = 3 ; // coluna
c . gridy = 8 ; // linha
textControlsPane . add ( jbc , c );
c . anchor = GridBagConstraints . LINE_END ;
c . gridx = 3 ; // coluna
c . gridy = 9 ; // linha
textControlsPane . add ( jbs , c );
jbs . addActionListener ( new ActionListener () {
@Override
public void actionPerformed ( ActionEvent e ) {
System . exit ( 0 );
}
});
textControlsPane . setBorder (
BorderFactory . createCompoundBorder (
BorderFactory . createTitledBorder ( "Cadastro de Cliente" ),
BorderFactory . createEmptyBorder ( 1 , 1 , 1 , 1 )));
textControlsPane . setPreferredSize ( new Dimension ( 600 , 350 ));
JPanel leftPane = new JPanel ( new BorderLayout ());
leftPane . add ( textControlsPane ,
BorderLayout . PAGE_START );
add ( leftPane , BorderLayout . LINE_START );
}
public static void main ( String [] args ) {
JFrame frame = new JFrame ( "Tela de Cadastro" );
frame . setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE );
frame . add ( new FrmCadCliente ());
frame . setPreferredSize ( new Dimension ( 650 , 400 ));
frame . pack ();
frame . setVisible ( true );
}
}
Allexb10 8 de nov. de 2011
Deu certo, Valeu Galera Muito obrigado pela ajuda, provavelmente em breve terei mais duvidas, hehe
Grande abraço!!!