Agora o codigo esta completo olha ai:
[code]package teste;
import teste.NovaTentativaGrid;
import teste.Clientes;
import javax.swing.JLabel;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JComboBox;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
public class Test extends JFrame implements ActionListener {
public static JLabel L1, L2;
private JLabel L3, L4, L5;
private JComboBox Cb;
private JTextField Txt1, Txt2;
public static JTextField Txt4, Txt3;
public static JTextArea TxtArquivo;
private JFileChooser Arquivo;
private JButton CmdConsultar, CmdGerar, CmdSair, CmdC;
public static JTable table;
public static DefaultTableModel model;
private JScrollPane js;
public static GridLayout grade;
private void setCenter(JFrame frame) {
Dimension paneSize = frame.getSize();
Dimension screenSize = frame.getToolkit().getScreenSize();
frame.setLocation( (screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);
}
public Test(){
setSize(800, 590);
setResizable(false);
setTitle("Envio de dados");
setCenter(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = getContentPane();
cp.setLayout(null);
DefaultTableModel model = new DefaultTableModel();
model.addTableModelListener(table);
model.addColumn("nome_cliente");
model.addColumn("endereco");
model.addColumn("cpf");
model.addColumn("cgc");
model.addColumn("Bairro");
model.addColumn("CEP");
model.addColumn("Telefone");
model.addColumn("data_vencto");
model.addColumn("data_compra");
model.addColumn("Valor Debito");
model.addColumn("cod_programa");
model.addColumn("numero_ligacao");
L5 = new JLabel (" Dados dos Clientes");
js = new JScrollPane (L5);
js.setBounds(50,60,115,21);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
table = new JTable();
table.setModel(model);
table.setAutoscrolls(rootPaneCheckingEnabled);
js = new JScrollPane(table);
js.setBounds(50,80,700,400);
//js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Arquivo = new JFileChooser(".");
L1 = new JLabel(" NSA");
js = new JScrollPane(L1);
js.setBounds(20,20,33,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Txt2 = new JTextField();//referente ao NSA
Txt2.addActionListener(this);
js = new JScrollPane(Txt2);
js.setBounds(60,20,170,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
L2 = new JLabel(" Caminho dos dados");
js = new JScrollPane(L2);
js.setBounds(250,20,120,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Txt1 = new JTextField();//referente ao caminho de dados
js = new JScrollPane(Txt1);
Txt1.addActionListener(this);
js.setBounds(380,20,250,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
CmdC = new JButton ("...");
CmdC.setBounds(640, 20, 25, 25);
CmdC.addActionListener(this);
cp.add(CmdC);
CmdConsultar = new JButton ("Consultar");
CmdConsultar.setBounds(680, 20, 90, 25);
CmdConsultar.addActionListener(this);
cp.add(CmdConsultar);
CmdGerar = new JButton("Gerar");
CmdGerar.setBounds(600,500,70,25);
CmdGerar.addActionListener(this);
cp.add(CmdGerar);
L3 = new JLabel(" Total de Clientes");
js = new JScrollPane(L3);
js.setBounds(50,500,105,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
//para receber o resultado da soma de numero de clientes
Txt3 = new JTextField();
js = new JScrollPane(Txt3);
js.setBounds(160,500,100,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
TxtArquivo = new JTextArea();
TxtArquivo.setVisible(false);
js = new JScrollPane(TxtArquivo);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
js.setBounds(50,80,700,400);
cp.add(js);
L4 = new JLabel(" Total de Debitos");
js = new JScrollPane(L4);
js.setBounds(310,500,100,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
//para receber o valor total de debitos dos clientes
Txt4 = new JTextField();
js = new JScrollPane(Txt4);
js.setBounds(420,500,100,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
CmdSair = new JButton("Sair");
CmdSair.setBounds(680,500,70,25);
CmdSair.addActionListener(this);
cp.add(CmdSair);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == CmdConsultar){
CmdConsultar = NovoRecebeBanco.main(null);
}
if(e.getSource() == CmdC){
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setLocation(0, 0);
// Esta linha alinha o JFileChooser no centro
int returnVal = chooser.showSaveDialog(null);
}
if(e.getSource() == CmdGerar){
if(Txt1.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null,"Digite o local onde voce quer salvar o arquivo");
}
if(Txt2.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null,"Digite um nome para gerar o arquivo");
} else {
int res = Arquivo.showSaveDialog(this);
if(res == JFileChooser.DIRECTORIES_ONLY){
File arq = Arquivo.getSelectedFile();
try{
salvar(TxtArquivo.getText(), arq.getPath());
} catch(IOException ioe){
JOptionPane.showMessageDialog(null, "Não foi possível salvar arquivo!");
}
}
}
}
if(e.getSource()== CmdSair){
this.dispose();
}
}
public void salvar(String nomeArq, String conteudoArq) throws IOException{
String txt = Txt1.getText();
PrintWriter out = new PrintWriter(new FileWriter(txt));
String txt2 = Txt2.getText();
out.print(txt2);
out.close();
JOptionPane.showMessageDialog(null, “Arquivo salvo com sucesso!”);
}
public static void main(String args[]) {
Test app = new Test();
app.show();
}
}
[/code]
A e o e.getSoucer eh refernete ao ActionPerformace dos butoes!
Me ajude por favor! :oops: