Galera, uma ajuda aqui, to implementando um sistema de coleta de informações, nesse caso uma que colete o estado (UF) e a descrição do estado(nome completo e etc). Porém alguma coisa tá errada, e os itens não são exibidos com a janela.
aqui vai o código.package Cadastros;
import javax.swing.*;
import java.awt.event.*;
public class CAD_uf extends JFrame{
/**criação das variáveis**/
JButton PB_novo, PB_gravar, PB_excluir, PB_alterar, PB_sair, PB_proximo, PB_anterior, PB_inicio, PB_final;
JFrame JF_janela;
JPanel JP_painel;
JLabel LB_uf,LB_descricao;
JTextField TF_uf, TF_descricao;
/*instanciamento das variáveis*/
public CAD_uf(){ //apenas public / public void => apenas controle
super(">>>>SISTEMA DE CADASTRO - UF<<<<");
// Container JF_janela = getContentPane();
// JF_janela.setLayout(null);
/*----Instanciamento do Frame----*/
JF_janela = new JFrame();
//painel
JP_painel = new JPanel();
/*-----Instanciamento Botões-----*/
PB_novo = new JButton();
PB_gravar = new JButton();
PB_alterar = new JButton();
PB_inicio = new JButton();
PB_anterior = new JButton();
PB_proximo = new JButton();
PB_excluir = new JButton();
PB_final = new JButton();
PB_sair = new JButton();
/*---Instanciamento dos Labels---*/
LB_uf = new JLabel();
LB_descricao= new JLabel();
/*--------Campos de Texto--------*/
TF_uf = new JTextField();
TF_descricao= new JTextField();
/*------------teclas-de-atalhos-------------*/
PB_alterar.setMnemonic (KeyEvent.VK_A);
PB_final.setMnemonic (KeyEvent.VK_F);
PB_gravar.setMnemonic (KeyEvent.VK_G);
PB_inicio.setMnemonic (KeyEvent.VK_I);
PB_novo.setMnemonic (KeyEvent.VK_N);
PB_anterior.setMnemonic (KeyEvent.VK_O);
PB_sair.setMnemonic (KeyEvent.VK_S);
PB_excluir.setMnemonic (KeyEvent.VK_X);
/*------Adicionando elementos à janela------*/
JF_janela.add(JP_painel);
JP_painel.add(LB_uf);
JP_painel.add(TF_uf);
JP_painel.add(LB_descricao);
JP_painel.add(TF_descricao);
JP_painel.add(PB_novo);
JP_painel.add(PB_gravar);
JP_painel.add(PB_alterar);
JP_painel.add(PB_inicio);
JP_painel.add(PB_anterior);
JP_painel.add(PB_proximo);
JP_painel.add(PB_excluir);
JP_painel.add(PB_final);
JP_painel.add(PB_sair);
setVisible(true);
setSize(800,600);
setLocationRelativeTo(null);
/* PB_sair.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int resposta;
resposta=JOptionPane.showConfirmDialog(null,"Deseja realmente sair?","Mensa" +
"gem do Programa",JOptionPane.YES_NO_OPTION);
if (resposta==0)
System.exit(0);
}
});
*/
}
public static void main (String args[]){
CAD_uf app = new CAD_uf();
app.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
Sinto que é algo bem básico, mas não consigo descobrir o que é... =\
