Problema com um botÃo

0 respostas
F
package PkgTrabalho; 
import java.awt.*; 
import java.awt.event.*; 

import javax.swing.*; 
import javax.swing.border.Border; 

import Principal.CardapioParte2; 
import Util.FormatMoeda; 
import Util.GBag; 
public class CadastroDeAlmoxarifado extends JFrame implements ActionListener{ 

private JButton btnConfima, btnCancela; 
private GridBagConstraints restricoes = new GridBagConstraints(); 
private JLabel lbl; 
private JTextField txtEndereco,txtAlmoxarifado,txtResponsavel,txtNumero,txtBairro,txtTelefone; 
{ 
addWindowListener(new WindowAdapter() 
{public void windowClosing(WindowEvent e){System.exit(0);}}); 

setSize(500,300); 
setLocation(150,150); 
setTitle(" Cadastro de Almoxarifados"); 



JPanel p1 = new JPanel(); 
p1.setLayout(new GridBagLayout()); 
GBag.restricoes.anchor = GridBagConstraints.WEST; 
GBag.restricoes.insets = new Insets(1,10,2,1); 
//GBag.restricoes.insets = new Insets(1,1,1,1); 

lbl = new JLabel ("Amoxarifado:"); 
GBag.addGridBag(p1,lbl,0,0); 
txtAlmoxarifado = new JTextField(40); 
GBag.addGridBag(p1,txtAlmoxarifado,0,1); 

lbl = new JLabel ("Responsável:"); 
GBag.addGridBag(p1,lbl,0,2); 
txtResponsavel = new JTextField(40); 
GBag.addGridBag(p1,txtResponsavel,0,3); 

JPanel p2 = new JPanel(); 
p2.setLayout(new GridBagLayout()); 
GBag.restricoes.anchor = GridBagConstraints.WEST; 
GBag.restricoes.insets = new Insets(1,10,10,1); 
lbl = new JLabel ("Endereço:"); 
GBag.addGridBag(p2,lbl,0,0); 
txtEndereco= new JTextField(30); 
GBag.addGridBag(p2,txtEndereco,0,1); 

lbl = new JLabel ("Numero:"); 
GBag.addGridBag(p2,lbl,1,0); 
txtNumero= new JTextField(; 
GBag.addGridBag(p2,txtNumero,1,1); 
// GBag.restricoes.insets = new Insets(1,1,1,1); 

JPanel p3 = new JPanel(); 
p3.setLayout(new GridBagLayout()); 
GBag.restricoes.anchor = GridBagConstraints.WEST; 
lbl = new JLabel ("Bairro:"); 
GBag.addGridBag(p3,lbl,0,0); 
txtBairro= new JTextField(40); 
GBag.addGridBag(p3,txtBairro,0,1); 

lbl = new JLabel ("Telefone:"); 
GBag.addGridBag(p3,lbl,0,2); 
txtTelefone= new JTextField(20); 
GBag.addGridBag(p3,txtTelefone,0,3); 

JPanel p4 = new JPanel(); 
p4.setLayout(new GridBagLayout()); 
GBag.restricoes.anchor = GridBagConstraints.EAST; 
btnConfima= new JButton("Confirma"); 
btnConfima.setForeground(Color.BLUE); 
GBag.addGridBag(p4,btnConfima,0,0); 

GBag.restricoes.anchor = GridBagConstraints.EAST; 
btnCancela= new JButton("Cancela"); 
btnCancela.setForeground(Color.BLUE); 
GBag.addGridBag(p4,btnCancela,1,0); 

GBag.restricoes.anchor = GridBagConstraints.WEST; 
JPanel pn1= new JPanel(); 
pn1.setLayout(new GridBagLayout()); 
pn1.add(p1,BorderLayout.NORTH); 
pn1.add(p2,BorderLayout.CENTER); 
pn1.add(p3,BorderLayout.SOUTH); 

JPanel pn2= new JPanel(); 
pn2.add(pn1,BorderLayout.SOUTH); 
pn2.add(p4,BorderLayout.NORTH); 




Container P = getContentPane(); 
P.add(pn2); 


} 

public static void main (String[] args) 
{ 

CadastroDeAlmoxarifado vc = new CadastroDeAlmoxarifado(); 
vc.setVisible(true); 
} 

@Override 
public void actionPerformed(ActionEvent e) { 
// TODO Auto-generated method stub 

} 
}

criei um JPanel( pn1) com tres JPanel(p1,p2,p3) dentro dele…

depois criei um outro JPanel(pn2) com o(pn1,p4) dentro dele… so que qdo rodo o programa ou fica todo desconfigurado ou da um erro…

POr favor da uma olhada em meu codigo e me ajudem…

Criado 23 de abril de 2008
Respostas 0
Participantes 1