:oops:Oi pessoal eu tenho um programa em java que faz a consulta no banco de dados e me retorna o resulta em um textArea, so que eu queria que esses dados ficassem dentro de uma tabela dentro do meu Frame, mas eu comecei a usar java faz pouco tempo e eu nunca criei uma tabela, naum sei nem como criar uma tem como dizer a quantidades de linhas e colunas ela tem que ter, alguem podem me ajudar esse eh o meu codigo!
package teste;
import javax.swing.JLabel;
public class LayoutConsulta extends JFrame implements ActionListener {
public static JLabel L1, L2;
private JLabel L3, L4, L5;
private JTextField Txt1, Txt2, Txt3, Txt4;
public static JTextArea TxtArquivo;
private JFileChooser Arquivo;
private JButton CmdConsultar, CmdGerar, CmdSair;
private JTable t1;
private JScrollPane js;
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 LayoutConsulta(){
setSize(800, 590);
setResizable(false);
setTitle("Envio de dados");
setCenter(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = getContentPane();
cp.setLayout(null);
Arquivo = new JFileChooser(".");
L1 = new JLabel(" NSA");
js = new JScrollPane(L1);
js.setBounds(20,30,33,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Txt2 = new JTextField();
js = new JScrollPane(Txt2);
js.setBounds(60,30,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,30,120,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Txt1 = new JTextField();
js = new JScrollPane(Txt1);
js.setBounds(380,30,290,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
CmdConsultar = new JButton ("Consultar");
CmdConsultar.setBounds(680, 30, 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(20,500,105,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
Txt3 = new JTextField();
js = new JScrollPane(Txt3);
js.setBounds(130,500,150,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
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);
Txt4 = new JTextField();
js = new JScrollPane(Txt4);
js.setBounds(420,500,150,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);
L5 = new JLabel (" Dados dos Clientes");
js = new JScrollPane (L5);
js.setBounds(70,80,120,25);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
TxtArquivo = new JTextArea();
TxtArquivo.setLineWrap(true);
js = new JScrollPane(TxtArquivo);
js.setBounds(70,105,650,350);
js.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cp.add(js);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == CmdConsultar){
CmdConsultar = NovoRecebeBanco.main(null);
}
if(e.getSource() == CmdGerar){
int res = Arquivo.showSaveDialog(this);
if(res == JFileChooser.APPROVE_OPTION){
File arq = Arquivo.getSelectedFile();
try{
escreveArquivo(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 escreveArquivo(String conteudo, String fileName) throws IOException {
PrintWriter out = new PrintWriter(new FileWriter(fileName));
out.print(conteudo);
out.close();
JOptionPane.showMessageDialog(null, "Arquivo salvo com sucesso!");
}
public static void main(String args[]) {
LayoutConsulta app = new LayoutConsulta();
app.show();
}
}
Bom pessoal o que eu preciso eh colacar no lugar do TextArea a tabela que ira receber os registros do banco!
Alguem ai pode me ajudar por favor
bjokas

