implementei o seguinte código
package com.br.SisConfrete;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class Principal extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
final static String principal = "Principal";
final static String cadastrarCliente = "Cadastrar Cliente";
final static String cadastrarEnvio = "Cadastrar Envio";
final static String consultarEnvio = " Consultar Envio";
final static String consultarCliente = "Consultar Cliente";
final static String cadastrarBoleto = "Cadastrar Boleto";
final static String consultarBoleto = "Consultar Boleto";
JButton botaoSalvar = new JButton("Salvar");
JButton botaoLimpar = new JButton("Limpar");
JButton botaoCancelar = new JButton("Cancelar");
JButton botaoSair = new JButton("Sair");
JButton botaoPesquisarNome = new JButton("Pesquisar");
JTable tabelaPesquisaNome = new JTable();
public void addComponentToPane(Container pane)
{
JTabbedPane painelAba = new JTabbedPane();
JButton botaoUm = new JButton("Fechar");
botaoUm.setBounds(10, 10, 780, 580);
botaoSalvar.setBounds(30, 450, 180, 50);
botaoLimpar.setBounds(218, 450, 180, 50);
botaoCancelar.setBounds(406, 450, 180, 50);
botaoSair.setBounds(595, 450, 180, 50);
botaoPesquisarNome.setBounds(320, 450, 180, 50);
tabelaPesquisaNome.setBounds(10, 120, 780, 300);
tabelaPesquisaNome.setBackground(new Color( 254, 66, 65));
botaoUm.addActionListener(this);
botaoSalvar.addActionListener(this);
botaoLimpar.addActionListener(this);
botaoCancelar.addActionListener(this);
botaoSair.addActionListener(this);
botaoPesquisarNome.addActionListener(this);
JLabel numeroCadastroCliente = new JLabel("Número Cadastro: ");
JLabel nomeCliente = new JLabel("Nome: ");
JLabel cpfCliente = new JLabel("CPF: ");
JLabel enderecoCliente = new JLabel("Rua: ");
JLabel numeroCliente = new JLabel("Número: ");
JLabel bairroCliente = new JLabel("Bairro: ");
JLabel cidadeCliente = new JLabel("Cidade: ");
JLabel ufCliente = new JLabel("Estado: ");
JLabel cepCliente = new JLabel("C.E.P.: ");
JTextField _numeroCadastroCliente = new JTextField("Número Cadastro", (20));
JTextField _nomeCliente = new JTextField("Nome", (50));
JTextField _cpfCliente = new JTextField("CPF", (11));
JTextField _enderecoCliente = new JTextField("Rua",(50));
JTextField _numeroCliente = new JTextField("Número",(5));
JTextField _bairroCliente = new JTextField("Bairro",(30));
JTextField _cidadeCliente = new JTextField("Cidade",(30));
JTextField _ufCliente = new JTextField("Estado",(3));
JTextField _cepCliente = new JTextField("C.E.P.",(12));
numeroCadastroCliente.setBounds(50,100,150,20);
nomeCliente.setBounds(50,124,50,20);
cpfCliente.setBounds(50,148,50,20);
enderecoCliente.setBounds(50,172,50,20);
numeroCliente.setBounds(50,196,80,20);
bairroCliente.setBounds(50,220,50,20);
cidadeCliente.setBounds(50,244,50,20);
ufCliente.setBounds(50,268,50,20);
cepCliente.setBounds(50,292,50,20);
_numeroCadastroCliente.setBounds(155,100,250,20);
_nomeCliente.setBounds(155,124,500,20);
_cpfCliente.setBounds(155,148,100,20);
_enderecoCliente.setBounds(155,172,250,20);
_numeroCliente.setBounds(155,196,80,20);
_bairroCliente.setBounds(155,220,250,20);
_cidadeCliente.setBounds(155,244,250,20);
_ufCliente.setBounds(155,268,50,20);
_cepCliente.setBounds(155,292,50,20);
JPanel tela1 = new JPanel()
{
private static final long serialVersionUID = 1L;
public Dimension getPreferredSize()
{
Dimension size = super.getPreferredSize();
size.width = 800;
size.height = 600;
return size;
}
};
tela1.setLayout(null);
tela1.add(botaoUm);
JPanel tela2 = new JPanel();
tela2.setLayout(null);
tela2.add(nomeCliente);
tela2.add(numeroCadastroCliente);
tela2.add(cpfCliente);
tela2.add(enderecoCliente);
tela2.add(numeroCliente);
tela2.add(bairroCliente);
tela2.add(cidadeCliente);
tela2.add(ufCliente);
tela2.add(cepCliente);
tela2.add(_nomeCliente);
tela2.add(_numeroCadastroCliente);
tela2.add(_cpfCliente);
tela2.add(_enderecoCliente);
tela2.add(_numeroCliente);
tela2.add(_bairroCliente);
tela2.add(_cidadeCliente);
tela2.add(_ufCliente);
tela2.add(_cepCliente);
tela2.add(botaoSalvar);
tela2.add(botaoLimpar);
tela2.add(botaoCancelar);
tela2.add(botaoSair);
JPanel tela3 = new JPanel();
tela3.setLayout(null);
tela3.add(botaoPesquisarNome);
tela3.add(tabelaPesquisaNome);
JPanel tela4 = new JPanel();
JPanel tela5 = new JPanel();
JPanel tela6 = new JPanel();
JPanel tela7 = new JPanel();
painelAba.addTab(consultarCliente, tela3);
painelAba.addTab(principal, tela1);
painelAba.addTab(cadastrarCliente, tela2);
painelAba.addTab(cadastrarEnvio, tela4);
painelAba.addTab(consultarEnvio, tela5);
painelAba.addTab(cadastrarBoleto, tela6);
painelAba.addTab(consultarBoleto, tela7);
pane.add(painelAba, BorderLayout.CENTER);
}
private static void ambienteGrafico()
{
JFrame frame = new JFrame("Sistema de Controle de Fretes");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
Principal demo = new Principal();
demo.addComponentToPane(frame.getContentPane());
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args)
{
/* Use an appropriate Look and Feel */
try
{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
catch (UnsupportedLookAndFeelException ex)
{
ex.printStackTrace();
}
catch (IllegalAccessException ex)
{
ex.printStackTrace();
}
catch (InstantiationException ex)
{
ex.printStackTrace();
}
catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}
UIManager.put("swing.boldMetal", Boolean.FALSE);
javax.swing.SwingUtilities.invokeLater
(
new Runnable()
{
public void run()
{
ambienteGrafico();
}
}
);
}
public void actionPerformed(ActionEvent e)
{
Object acaoBotao = e.getSource();
if (acaoBotao == botaoSair)
{
System.exit(0);
}
}
}
ta funcionando mas, eu queria saber como coloco os nomes nas colunas.
na tela3 a intenção é que o usuario digite o nome do cliente e apareça numa tabela as seguintes informações:
Endereço, ultima envio, ultimo boleto, data da entrega
uma boa noite a todos…