Olá.
Oi eu estou com dificuldades, de fazer as minhas informações da tela cadastro_de_cliente, aparecerem nessa janela, tenho que colocar os campos no lugar, mas não consigo visualiza-los já que ele não aparecem, poderiam me ajudar a resolver este problema .
a janela que quero é está, mas feita em código. o que posso fazer para obter este resultado?
Obrigado.!
import java.awt.Color;
import java.text.ParseException;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.text.MaskFormatter;
public class cadastro_de_cliente extends JFrame{
private JLabel lblcodigo;
private JTextField txtcodigo;
private JLabel lblnome;
private JTextField txtnome;
private JLabel lblendereco;
private JTextField txtendereco;
private JLabel lblcpf;
private JFormattedTextField txtcpf;
private JLabel lbltelefone;
private JFormattedTextField txttelefone;
private JLabel lblrg;
private JFormattedTextField txtrg;
private JButton btsalvar;
private JButton btnovo;
private JButton btsair;
public cadastro_de_cliente() {
super("cadastro");
setSize(800,600);
setLocation(150,150);
setTitle("Cliente");
setVisible(true);
setResizable(false);
getContentPane().setBackground(Color.gray);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main (String [] args) {
new cadastro_de_cliente().setVisible(true);
}
public void layout() {
lblcodigo = new JLabel("Código:");
txtcodigo = new JTextField();
lblnome = new JLabel("Nome:");
txtnome = new JTextField();
lblendereco = new JLabel("Endereço:");
txtendereco = new JTextField();
lblcpf = new JLabel("CPF:");
try {
txtcpf = new JFormattedTextField(new MaskFormatter("###.###.###-##"));
}catch (ParseException e) {
e.printStackTrace();
}
lbltelefone = new JLabel("Telefone:");
try {
txttelefone = new JFormattedTextField(new MaskFormatter("(###)#####-####"));
}catch(ParseException e) {
e.printStackTrace();
}
lblrg = new JLabel("RG");
try {
txtrg = new JFormattedTextField(new MaskFormatter("**-###.###.##"));
}catch(ParseException e) {
e.printStackTrace();
}
btsalvar = new JButton("Salvar");
btnovo = new JButton("Novo");
btsair = new JButton("Sair");
lblcodigo.setBounds(0,0,100,25);
txtcodigo.setBounds(150,0,200,25);
lblnome.setBounds(0,0,100,25);
txtnome.setBounds(0,90,100,25);
lblendereco.setBounds(80,78,100,25);
txtendereco.setBounds(150,45,100,25);
lbltelefone.setBounds(83,46,30,25);
txttelefone.setBounds(76,45,100,25);
lblcpf.setBounds(34,46,100,25);
txtcpf.setBounds(67,26,100,25);
lblrg.setBounds(85,98,100,25);
txtrg.setBounds(36,28,100,25);
btsalvar.setBounds(28,28,29,35);
btnovo.setBounds(23,37,98,29);
btsair.setBounds(72,38,19,39);
}}