Dificuldade em Organizar os Componentes no Layout

13 respostas Resolvido
java
O

Bloco de Citação

package pacoteCadastro;

import java.awt.Color;

import java.awt.Dimension;

import java.awt.FlowLayout;

import java.awt.Font;

import java.awt.Frame;
import javax.swing.BorderFactory;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.SwingConstants;

import javax.swing.border.Border;

import javax.swing.border.TitledBorder;

public class TelaLogin extends JFrame {

private JPanel painel = new JPanel();
Border bord = BorderFactory.createLineBorder(Color.BLACK);
TitledBorder tituloBorda = BorderFactory.createTitledBorder(bord, "Dados para carregamento");
TitledBorder titulolacre = BorderFactory.createTitledBorder(bord, "Lacres");
private JLabel lbCodigo = new JLabel("Código ", SwingConstants.RIGHT);
private JLabel lbNome = new JLabel("Nome ", SwingConstants.RIGHT);
private JLabel lbCapacidade = new JLabel("Capacidade", SwingConstants.RIGHT);
private JLabel lbCpf = new JLabel("Cpf", SwingConstants.RIGHT);
private JLabel lbCavalo = new JLabel("Placa", SwingConstants.RIGHT);
private JLabel lbReboque01 = new JLabel("01", SwingConstants.RIGHT);
private JLabel lbReboque02 = new JLabel("02", SwingConstants.RIGHT);
private JLabel lbTransportadora = new JLabel("Transp", SwingConstants.RIGHT);
private JLabel lbDestino = new JLabel("Destino", SwingConstants.RIGHT);
private JLabel lbTipo = new JLabel("Tipo", SwingConstants.RIGHT);
private JLabel lbChegada = new JLabel("Chegada", SwingConstants.RIGHT);
private JLabel lbAgendado = new JLabel("Agendado", SwingConstants.RIGHT);

private JTextField txtCodigo = new JTextField();
private JTextField txtNome = new JTextField();
private JTextField txtCpf = new JTextField();
private JTextField txtCapacidade = new JTextField();
private JTextField txtCavalo = new JTextField();
private JTextField txtReboque01 = new JTextField();
private JTextField txtReboque02 = new JTextField();
private JComboBox<?> cbTransportadora = new JComboBox<>();
private JComboBox<?> cbDestino = new JComboBox<>();
private JComboBox<?> cbTipo = new JComboBox<>();
private JTextField txtChegada = new JTextField();
private JTextField txtAgendado = new JTextField();

private void configuraPainel() {
	
	JFrame tela = new JFrame();
	tela.setSize(800,800);
	tela.setResizable(false);
	tela.setTitle("Cadastro de Clientes - Acesso");
	tela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	tela.getContentPane().setBackground(new Color(200, 200, 200));
	tela.setLayout(null);
	
	painel.setBounds(40, 75, 500, 500);
	painel.setBackground(Color.CYAN);
	painel.setBorder(tituloBorda);
	painel.setLayout(new FlowLayout());

	
	tela.add(painel);
	tela.setVisible(true);
}

public TelaLogin() {

	configuraPainel();

	lbCodigo.setForeground(Color.BLACK);
	lbCodigo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCodigo.setLocation(10, 10);
	painel.add(lbCodigo);

	txtCodigo.setForeground(Color.BLACK);
	txtCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCodigo.setLocation(10, 10);
	txtCodigo.setPreferredSize(new Dimension(50, 20));
	painel.add(txtCodigo);

	
	lbNome.setForeground(Color.BLACK);
	lbNome.setFont(new Font("Ubuntu", Font.BOLD, 10));
	painel.add(lbNome);

	txtNome.setForeground(Color.BLACK);
	txtNome.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtNome.setLocation(20, 20);
	txtNome.setPreferredSize(new Dimension(50,20));
	painel.add(txtNome);
/*

lbCpf.setForeground(Color.BLACK);

lbCpf.setFont(new Font(Ubuntu, Font.BOLD, 10));

lbCpf.setBounds(10, 80, 70, 15);

painel.add(lbCpf);
txtCpf.setForeground(Color.BLACK);
	txtCpf.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCpf.setBounds(90, 80, 150, 20);
	painel.add(txtCpf);

	lbCapacidade.setForeground(Color.BLACK);
	lbCapacidade.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCapacidade.setBounds(10, 110, 70, 15);
	painel.add(lbCapacidade);

	txtCapacidade.setForeground(Color.BLACK);
	txtCapacidade.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCapacidade.setBounds(90, 110, 70, 20);
	painel.add(txtCapacidade);

	lbCavalo.setForeground(Color.BLACK);
	lbCavalo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCavalo.setBounds(10, 140, 70, 15);
	painel.add(lbCavalo);

	txtCavalo.setForeground(Color.BLACK);
	txtCavalo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCavalo.setBounds(90, 140, 70, 20);
	painel.add(txtCavalo);

	lbReboque01.setForeground(Color.BLACK);
	lbReboque01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbReboque01.setBounds(110, 140, 70, 15);
	painel.add(lbReboque01);

	txtReboque01.setForeground(Color.BLACK);
	txtReboque01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtReboque01.setBounds(190, 140, 70, 20);
	painel.add(txtReboque01);

	lbReboque02.setForeground(Color.BLACK);
	lbReboque02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbReboque02.setBounds(210, 140, 70, 15);
	painel.add(lbReboque02);

	txtReboque02.setForeground(Color.BLACK);
	txtReboque02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtReboque02.setBounds(290, 140, 70, 20);
	painel.add(txtReboque02);

	lbTransportadora.setForeground(Color.BLACK);
	lbTransportadora.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbTransportadora.setBounds(10, 170, 70, 15);
	painel.add(lbTransportadora);

	cbTransportadora.setForeground(Color.BLACK);
	cbTransportadora.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbTransportadora.setBounds(90, 170, 150, 20);
	painel.add(cbTransportadora);

	lbDestino.setForeground(Color.BLACK);
	lbDestino.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbDestino.setBounds(10, 200, 70, 15);
	painel.add(lbDestino);

	cbDestino.setForeground(Color.BLACK);
	cbDestino.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbDestino.setBounds(90, 200, 150, 20);
	painel.add(cbDestino);

	lbTipo.setForeground(Color.BLACK);
	lbTipo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbTipo.setBounds(10, 230, 70, 15);
	painel.add(lbTipo);

	cbTipo.setForeground(Color.BLACK);
	cbTipo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbTipo.setBounds(90, 230, 150, 20);
	painel.add(cbTipo);

	lbChegada.setForeground(Color.BLACK);
	lbChegada.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbChegada.setBounds(10, 260, 70, 15);
	painel.add(lbChegada);

	txtChegada.setForeground(Color.BLACK);
	txtChegada.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtChegada.setBounds(90, 260, 150, 20);
	painel.add(txtChegada);

	lbAgendado.setForeground(Color.BLACK);
	lbAgendado.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbAgendado.setBounds(10, 290, 70, 15);
	painel.add(lbAgendado);

	txtAgendado.setForeground(Color.BLACK);
	txtAgendado.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtAgendado.setBounds(90, 290, 150, 20);
	painel.add(txtAgendado);*/

}

}

Não consigo alinhar meus componentes no JPanel

13 Respostas

J

Fazer layout de forma manual hoje em dia é auto flagelação mental.
Demora muito, se for aquelas telas de ERP com muitas informações e precisar ficar esticando e encolhendo componentes dá muito trabalho.

Se quer mesmo aprender como as coisas funcionam é bem mais simples que tudo isso.

Uma ferramenta que ajuda a arrastar os componentes e a possibilidade de ver o fonte tanto do resultado da tela quanto da biblioteca em si, isso é mais que suficiente para aprender.

Pra falar a minha verdade nunca gostei muito de fazer tela manual, sempre recorri a algo de maior produtividade.

Em Swing que é o que voce esta desenvolvendo a coisa de telas complexas o bicho fica brabo se for manual, tanto pra você que está aprendendo quanto para programadores experientes.

J

Se existe um editor visual pra Swing, pq escrever na mão todo esse código?

Lógico que pode ter situações mais dinâmicas em que o editor visual possa não atender. Mas pra maioria dos casos que o editor visual atende, só vai perder tempo.

O

J-MENEZES, como disse em um outro debate, estou desenvolvendo na unha afim de compreender os acontecimentos e ganhar um pouco de conhecimento nas funcionalidades java, não que eu não goste de um aplicativo facilitador que ajuda no desenvolvimento em si, meu plano agora é aprender, e de que adianta eu ficar arrastando e soltando componentes sem entender por trás as suas funcionalidades, parece flagelação mental como vc disse, mas cada um tem um jeito de aprender e esse é o meu, peço dicas e ajuda aqui, para agregar conhecimento, agora se o seu jeito em aprender ou ensinar é arrastando e soltando tranquilo, sem problemas vc não irá conseguir me ajudar.

Obrigado, abçs .

J
Solucao aceita

Ele conseguiu ajudar sim. Só estamos te ensinando a pescar ao invés de toda hora te dar um peixe

Se observar como é gerado o código pelo editor visual, terá essa e muitas outras respostas sem precisar de uma pessoa pra te responder. Se quer tanto insistir em fazer na mão, faz, mas pode pelo menos usar o editor visual pra saber como se faz tal coisa, basta estudar o código gerado a cada mudança. Pode ter dois projetos, um temporário com editor visual pra observar o que é gerado e outro seu projeto pra valer.

O

Tranquilo meu amigo, reconheço que fui grosso ao responder.

Excelente dia

S

Como é que você quer alinhar os componentes da sua tela?
Faz um desenho de como quer que sua tela pareça e posta aqui.
Te oriento como montar o layout na munheca.
:wink:

O

Staroski boa noite,

Em eu consegui batendo a cabeça mas deu certo, vou postar a imagem e o código que utilizei, se caso conseguir sugerir melhoria e desempenho fico grato.

O

Eu não sei como colocar o código dentro de uma citação aqui para ficar ele completo para vc ver.

O

O

Bloco de Citação

package pacoteCadastro;

import java.awt.Color;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;
import javax.swing.BorderFactory;

import javax.swing.JButton;

import javax.swing.JCheckBox;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.SwingConstants;

import javax.swing.border.Border;

import javax.swing.border.TitledBorder;

public class TelaLogin extends JFrame {

private JPanel painel = new JPanel();
private JPanel painel_produto = new JPanel();
private JPanel painel_Lacres = new JPanel();
Border bord = BorderFactory.createLineBorder(Color.BLACK);
TitledBorder tituloBorda = BorderFactory.createTitledBorder(bord, "Dados para carregamento");
TitledBorder tituloProdutos = BorderFactory.createTitledBorder(bord, "Produtos");
TitledBorder tituloLacres = BorderFactory.createTitledBorder(bord, "Lacres");
private JLabel lbCodigo = new JLabel("Código ", SwingConstants.RIGHT);
private JLabel lbNome = new JLabel("Nome ", SwingConstants.RIGHT);
private JLabel lbCapacidade = new JLabel("Capacidade", SwingConstants.RIGHT);
private JLabel lbCpf = new JLabel("Cpf", SwingConstants.RIGHT);
private JLabel lbCavalo = new JLabel("Placa", SwingConstants.RIGHT);
private JLabel lbReboque01 = new JLabel("01", SwingConstants.RIGHT);
private JLabel lbReboque02 = new JLabel("02", SwingConstants.RIGHT);
private JLabel lbTransportadora = new JLabel("Transp", SwingConstants.RIGHT);
private JLabel lbDestino = new JLabel("Destino", SwingConstants.RIGHT);
private JLabel lbTipo = new JLabel("Tipo", SwingConstants.RIGHT);
private JLabel lbChegada = new JLabel("Chegada", SwingConstants.RIGHT);
private JLabel lbAgendado = new JLabel("Agendado", SwingConstants.RIGHT);
private JLabel lbLacre01 = new JLabel("01", SwingConstants.RIGHT);
private JLabel lbLacre02 = new JLabel("02", SwingConstants.RIGHT);
private JLabel lbLacre03 = new JLabel("03", SwingConstants.RIGHT);
private JLabel lbLacre04 = new JLabel("04", SwingConstants.RIGHT);
private JLabel lbLacre05 = new JLabel("05", SwingConstants.RIGHT);
private JLabel lbLacre06 = new JLabel("06", SwingConstants.RIGHT);
private JLabel lbLacre07 = new JLabel("07", SwingConstants.RIGHT);
private JLabel lbLacre08 = new JLabel("08", SwingConstants.RIGHT);
private JLabel lbLacre09 = new JLabel("09", SwingConstants.RIGHT);
private JLabel lbLacre10 = new JLabel("10", SwingConstants.RIGHT);
private JLabel lbLacre11 = new JLabel("11", SwingConstants.RIGHT);
private JLabel lbLacre12 = new JLabel("12", SwingConstants.RIGHT);
private JLabel lbLacre13 = new JLabel("13", SwingConstants.RIGHT);
private JLabel lbLacre14 = new JLabel("14", SwingConstants.RIGHT);
private JLabel lbLacre15 = new JLabel("15", SwingConstants.RIGHT);
private JLabel lbLacre16 = new JLabel("16", SwingConstants.RIGHT);
private JLabel lbLacre17 = new JLabel("17", SwingConstants.RIGHT);
private JLabel lbLacre18 = new JLabel("18", SwingConstants.RIGHT);
private JLabel lbLacre19 = new JLabel("19", SwingConstants.RIGHT);
private JLabel lbLacre20 = new JLabel("20", SwingConstants.RIGHT);
private JLabel lbLacre21 = new JLabel("21", SwingConstants.RIGHT);
private JLabel lbLacre22 = new JLabel("20", SwingConstants.RIGHT);
private JLabel lbLacre23 = new JLabel("23", SwingConstants.RIGHT);
private JLabel lbLacre24 = new JLabel("24", SwingConstants.RIGHT);
private JLabel lbLacre25 = new JLabel("25", SwingConstants.RIGHT);
private JLabel lbLacre26 = new JLabel("26", SwingConstants.RIGHT);
private JLabel lbLacre27 = new JLabel("27", SwingConstants.RIGHT);
private JLabel lbLacre28 = new JLabel("28", SwingConstants.RIGHT);
private JLabel lbLacre29 = new JLabel("29", SwingConstants.RIGHT);
private JLabel lbLacre30 = new JLabel("30", SwingConstants.RIGHT);
private JLabel lbLacre31 = new JLabel("31", SwingConstants.RIGHT);
private JLabel lbLacre32 = new JLabel("32", SwingConstants.RIGHT);
private JLabel lbLacre33 = new JLabel("33", SwingConstants.RIGHT);
private JLabel lbLacre34 = new JLabel("34", SwingConstants.RIGHT);
private JLabel lbLacre35 = new JLabel("35", SwingConstants.RIGHT);
private JLabel lbLacre36 = new JLabel("36", SwingConstants.RIGHT);

private JTextField txtCodigo = new JTextField();
private JTextField txtNome = new JTextField();
private JTextField txtCpf = new JTextField();
private JTextField txtCapacidade = new JTextField();
private JTextField txtCavalo = new JTextField();
private JTextField txtReboque01 = new JTextField();
private JTextField txtReboque02 = new JTextField();
private JComboBox<?> cbTransportadora = new JComboBox<>();
private JComboBox<?> cbDestino = new JComboBox<>();
private JComboBox<?> cbTipo = new JComboBox<>();
private JTextField txtChegada = new JTextField();
private JTextField txtAgendado = new JTextField();
private JTextField txtLacre01 = new JTextField();
private JTextField txtLacre02 = new JTextField();
private JTextField txtLacre03 = new JTextField();
private JTextField txtLacre04 = new JTextField();
private JTextField txtLacre05 = new JTextField();
private JTextField txtLacre06 = new JTextField();
private JTextField txtLacre07 = new JTextField();
private JTextField txtLacre08 = new JTextField();
private JTextField txtLacre09 = new JTextField();
private JTextField txtLacre10 = new JTextField();
private JTextField txtLacre11 = new JTextField();
private JTextField txtLacre12 = new JTextField();
private JTextField txtLacre13 = new JTextField();
private JTextField txtLacre14 = new JTextField();
private JTextField txtLacre15 = new JTextField();
private JTextField txtLacre16 = new JTextField();
private JTextField txtLacre17 = new JTextField();
private JTextField txtLacre18 = new JTextField();
private JTextField txtLacre19 = new JTextField();
private JTextField txtLacre20 = new JTextField();
private JTextField txtLacre21 = new JTextField();
private JTextField txtLacre22 = new JTextField();
private JTextField txtLacre23 = new JTextField();
private JTextField txtLacre24 = new JTextField();
private JTextField txtLacre25 = new JTextField();
private JTextField txtLacre26 = new JTextField();
private JTextField txtLacre27 = new JTextField();
private JTextField txtLacre28 = new JTextField();
private JTextField txtLacre29 = new JTextField();
private JTextField txtLacre30 = new JTextField();
private JTextField txtLacre31 = new JTextField();
private JTextField txtLacre32 = new JTextField();
private JTextField txtLacre33 = new JTextField();
private JTextField txtLacre34 = new JTextField();
private JTextField txtLacre35 = new JTextField();
private JTextField txtLacre36 = new JTextField();
private JCheckBox opHidratado = new JCheckBox("Hidratado");
private JCheckBox opAnidro = new JCheckBox("Anidro");
private JCheckBox opAcucar = new JCheckBox("Açucar");

private void configuraPainel() {
	
	JFrame tela = new JFrame();
	tela.setSize(900, 450);
	tela.setResizable(false);
	tela.setTitle("Cadastro de Clientes - Acesso");
	tela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	tela.getContentPane().setBackground(new Color(200, 200, 200));
	tela.setLayout(null);
	
	painel.setBounds(130, 20, 375, 325);
	painel.setBackground(Color.LIGHT_GRAY);
	painel.setBorder(tituloBorda);
	painel.setLayout(null);
	
	painel_produto.setBounds(10, 20, 100, 140);
	painel_produto.setBackground(Color.LIGHT_GRAY);
	painel_produto.setBorder(tituloProdutos);
	painel_produto.setLayout(null);

	painel_Lacres.setBounds(525, 20, 350, 390);
	painel_Lacres.setBackground(Color.LIGHT_GRAY);
	painel_Lacres.setBorder(tituloLacres);
	painel_Lacres.setLayout(null);
	
	tela.add(painel_Lacres);
	tela.add(painel_produto);
	tela.add(painel);
	tela.setVisible(true);
}

public TelaLogin() {

	configuraPainel();
	
	opHidratado.setForeground(Color.BLACK);
	opHidratado.setFont(new Font("Ubuntu", Font.BOLD, 10));
	opHidratado.setBounds(5, 20, 80, 15);
	painel_produto.add(opHidratado);
	
	opAnidro.setForeground(Color.BLACK);
	opAnidro.setFont(new Font("Ubuntu", Font.BOLD, 10));
	opAnidro.setBounds(5, 45, 80, 15);
	painel_produto.add(opAnidro);
	
	opAcucar.setForeground(Color.BLACK);
	opAcucar.setFont(new Font("Ubuntu", Font.BOLD, 10));
	opAcucar.setBounds(5, 70, 80, 15);
	painel_produto.add(opAcucar);


	lbCodigo.setForeground(Color.BLACK);
	lbCodigo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCodigo.setBounds(5, 20, 70, 15);
	painel.add(lbCodigo);

	txtCodigo.setForeground(Color.BLACK);
	txtCodigo.setHorizontalAlignment(SwingConstants.CENTER);
	txtCodigo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCodigo.setBounds(90, 20, 60, 20);
	painel.add(txtCodigo);

	
	lbNome.setForeground(Color.BLACK);
	lbNome.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbNome.setBounds(10, 50, 70, 15);
	painel.add(lbNome);

	txtNome.setForeground(Color.BLACK);
	txtNome.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtNome.setBounds(90, 50, 150, 20);
	painel.add(txtNome);

	lbCpf.setForeground(Color.BLACK);
	lbCpf.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCpf.setBounds(10, 80, 70, 15);
	painel.add(lbCpf);

	txtCpf.setForeground(Color.BLACK);
	txtCpf.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCpf.setBounds(90, 80, 150, 20);
	painel.add(txtCpf);

	lbCapacidade.setForeground(Color.BLACK);
	lbCapacidade.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCapacidade.setBounds(10, 110, 70, 15);
	painel.add(lbCapacidade);

	txtCapacidade.setForeground(Color.BLACK);
	txtCapacidade.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCapacidade.setBounds(90, 110, 70, 20);
	painel.add(txtCapacidade);

	lbCavalo.setForeground(Color.BLACK);
	lbCavalo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbCavalo.setBounds(10, 140, 70, 15);
	painel.add(lbCavalo);

	txtCavalo.setForeground(Color.BLACK);
	txtCavalo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtCavalo.setBounds(90, 140, 70, 20);
	painel.add(txtCavalo);

	lbReboque01.setForeground(Color.BLACK);
	lbReboque01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbReboque01.setBounds(110, 140, 70, 15);
	painel.add(lbReboque01);

	txtReboque01.setForeground(Color.BLACK);
	txtReboque01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtReboque01.setBounds(190, 140, 70, 20);
	painel.add(txtReboque01);

	lbReboque02.setForeground(Color.BLACK);
	lbReboque02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbReboque02.setBounds(210, 140, 70, 15);
	painel.add(lbReboque02);

	txtReboque02.setForeground(Color.BLACK);
	txtReboque02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtReboque02.setBounds(290, 140, 70, 20);
	painel.add(txtReboque02);

	lbTransportadora.setForeground(Color.BLACK);
	lbTransportadora.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbTransportadora.setBounds(10, 170, 70, 15);
	painel.add(lbTransportadora);

	cbTransportadora.setForeground(Color.BLACK);
	cbTransportadora.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbTransportadora.setBounds(90, 170, 150, 20);
	painel.add(cbTransportadora);

	lbDestino.setForeground(Color.BLACK);
	lbDestino.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbDestino.setBounds(10, 200, 70, 15);
	painel.add(lbDestino);

	cbDestino.setForeground(Color.BLACK);
	cbDestino.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbDestino.setBounds(90, 200, 150, 20);
	painel.add(cbDestino);

	lbTipo.setForeground(Color.BLACK);
	lbTipo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbTipo.setBounds(10, 230, 70, 15);
	painel.add(lbTipo);

	cbTipo.setForeground(Color.BLACK);
	cbTipo.setFont(new Font("Ubuntu", Font.BOLD, 10));
	cbTipo.setBounds(90, 230, 150, 20);
	painel.add(cbTipo);

	lbChegada.setForeground(Color.BLACK);
	lbChegada.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbChegada.setBounds(10, 260, 70, 15);
	painel.add(lbChegada);

	txtChegada.setForeground(Color.BLACK);
	txtChegada.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtChegada.setBounds(90, 260, 150, 20);
	painel.add(txtChegada);

	lbAgendado.setForeground(Color.BLACK);
	lbAgendado.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbAgendado.setBounds(10, 290, 70, 15);
	painel.add(lbAgendado);

	txtAgendado.setForeground(Color.BLACK);
	txtAgendado.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtAgendado.setBounds(90, 290, 150, 20);
	painel.add(txtAgendado);
	
	
	/* Lacres */
	
	lbLacre01.setForeground(Color.BLACK);
	lbLacre01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre01.setBounds(10, 20, 15, 15);
	painel_Lacres.add(lbLacre01);

	txtLacre01.setForeground(Color.BLACK);
	txtLacre01.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre01.setBounds(35, 20, 70, 20);
	painel_Lacres.add(txtLacre01);
	
	lbLacre02.setForeground(Color.BLACK);
	lbLacre02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre02.setBounds(10, 50, 15, 15);
	painel_Lacres.add(lbLacre02);

	txtLacre02.setForeground(Color.BLACK);
	txtLacre02.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre02.setBounds(35, 50, 70, 20);
	painel_Lacres.add(txtLacre02);
	
	lbLacre03.setForeground(Color.BLACK);
	lbLacre03.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre03.setBounds(10, 80, 15, 15);
	painel_Lacres.add(lbLacre03);

	txtLacre03.setForeground(Color.BLACK);
	txtLacre03.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre03.setBounds(35, 80, 70, 20);
	painel_Lacres.add(txtLacre03);
	
	lbLacre04.setForeground(Color.BLACK);
	lbLacre04.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre04.setBounds(10, 110, 15, 15);
	painel_Lacres.add(lbLacre04);

	txtLacre04.setForeground(Color.BLACK);
	txtLacre04.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre04.setBounds(35, 110, 70, 20);
	painel_Lacres.add(txtLacre04);
	
	lbLacre05.setForeground(Color.BLACK);
	lbLacre05.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre05.setBounds(10, 140, 15, 15);
	painel_Lacres.add(lbLacre05);

	txtLacre05.setForeground(Color.BLACK);
	txtLacre05.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre05.setBounds(35, 140, 70, 20);
	painel_Lacres.add(txtLacre05);
	
	lbLacre06.setForeground(Color.BLACK);
	lbLacre06.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre06.setBounds(10, 170, 15, 15);
	painel_Lacres.add(lbLacre06);

	txtLacre06.setForeground(Color.BLACK);
	txtLacre06.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre06.setBounds(35, 170, 70, 20);
	painel_Lacres.add(txtLacre06);
	
	lbLacre07.setForeground(Color.BLACK);
	lbLacre07.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre07.setBounds(10, 200, 15, 15);
	painel_Lacres.add(lbLacre07);

	txtLacre07.setForeground(Color.BLACK);
	txtLacre07.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre07.setBounds(35, 200, 70, 20);
	painel_Lacres.add(txtLacre07);
	
	lbLacre08.setForeground(Color.BLACK);
	lbLacre08.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre08.setBounds(10, 230, 15, 15);
	painel_Lacres.add(lbLacre08);

	txtLacre08.setForeground(Color.BLACK);
	txtLacre08.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre08.setBounds(35, 230, 70, 20);
	painel_Lacres.add(txtLacre08);
	
	lbLacre09.setForeground(Color.BLACK);
	lbLacre09.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre09.setBounds(10, 260, 15, 15);
	painel_Lacres.add(lbLacre09);

	txtLacre09.setForeground(Color.BLACK);
	txtLacre09.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre09.setBounds(35, 260, 70, 20);
	painel_Lacres.add(txtLacre09);
	
	lbLacre10.setForeground(Color.BLACK);
	lbLacre10.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre10.setBounds(10, 290, 15, 15);
	painel_Lacres.add(lbLacre10);

	txtLacre10.setForeground(Color.BLACK);
	txtLacre10.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre10.setBounds(35, 290, 70, 20);
	painel_Lacres.add(txtLacre10);
	
	lbLacre11.setForeground(Color.BLACK);
	lbLacre11.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre11.setBounds(10, 320, 15, 15);
	painel_Lacres.add(lbLacre11);

	txtLacre11.setForeground(Color.BLACK);
	txtLacre11.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre11.setBounds(35, 320, 70, 20);
	painel_Lacres.add(txtLacre11);
	
	lbLacre12.setForeground(Color.BLACK);
	lbLacre12.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre12.setBounds(10, 350, 15, 15);
	painel_Lacres.add(lbLacre12);

	txtLacre12.setForeground(Color.BLACK);
	txtLacre12.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre12.setBounds(35, 350, 70, 20);
	painel_Lacres.add(txtLacre12);
	
	lbLacre13.setForeground(Color.BLACK);
	lbLacre13.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre13.setBounds(115, 20, 15, 15);
	painel_Lacres.add(lbLacre13);

	txtLacre13.setForeground(Color.BLACK);
	txtLacre13.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre13.setBounds(145, 20, 70, 20);
	painel_Lacres.add(txtLacre13);
	
	lbLacre14.setForeground(Color.BLACK);
	lbLacre14.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre14.setBounds(115, 50, 15, 15);
	painel_Lacres.add(lbLacre14);

	txtLacre14.setForeground(Color.BLACK);
	txtLacre14.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre14.setBounds(145, 50, 70, 20);
	painel_Lacres.add(txtLacre14);
	
	lbLacre15.setForeground(Color.BLACK);
	lbLacre15.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre15.setBounds(115, 80, 15, 15);
	painel_Lacres.add(lbLacre15);

	txtLacre15.setForeground(Color.BLACK);
	txtLacre15.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre15.setBounds(145, 80, 70, 20);
	painel_Lacres.add(txtLacre15);
	
	lbLacre16.setForeground(Color.BLACK);
	lbLacre16.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre16.setBounds(115, 110, 15, 15);
	painel_Lacres.add(lbLacre16);

	txtLacre16.setForeground(Color.BLACK);
	txtLacre16.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre16.setBounds(145, 110, 70, 20);
	painel_Lacres.add(txtLacre16);
	
	lbLacre17.setForeground(Color.BLACK);
	lbLacre17.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre17.setBounds(115, 140, 15, 15);
	painel_Lacres.add(lbLacre17);

	txtLacre17.setForeground(Color.BLACK);
	txtLacre17.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre17.setBounds(145, 140, 70, 20);
	painel_Lacres.add(txtLacre17);
	
	lbLacre18.setForeground(Color.BLACK);
	lbLacre18.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre18.setBounds(115, 170, 15, 15);
	painel_Lacres.add(lbLacre18);

	txtLacre18.setForeground(Color.BLACK);
	txtLacre18.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre18.setBounds(145, 170, 70, 20);
	painel_Lacres.add(txtLacre18);
	
	lbLacre19.setForeground(Color.BLACK);
	lbLacre19.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre19.setBounds(115, 200, 15, 15);
	painel_Lacres.add(lbLacre19);

	txtLacre19.setForeground(Color.BLACK);
	txtLacre19.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre19.setBounds(145, 200, 70, 20);
	painel_Lacres.add(txtLacre19);
	
	lbLacre20.setForeground(Color.BLACK);
	lbLacre20.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre20.setBounds(115, 230, 15, 15);
	painel_Lacres.add(lbLacre20);

	txtLacre20.setForeground(Color.BLACK);
	txtLacre20.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre20.setBounds(145, 230, 70, 20);
	painel_Lacres.add(txtLacre20);
	
	lbLacre21.setForeground(Color.BLACK);
	lbLacre21.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre21.setBounds(115, 260, 15, 15);
	painel_Lacres.add(lbLacre21);

	txtLacre21.setForeground(Color.BLACK);
	txtLacre21.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre21.setBounds(145, 260, 70, 20);
	painel_Lacres.add(txtLacre21);
	
	lbLacre22.setForeground(Color.BLACK);
	lbLacre22.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre22.setBounds(115, 290, 15, 15);
	painel_Lacres.add(lbLacre22);

	txtLacre22.setForeground(Color.BLACK);
	txtLacre22.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre22.setBounds(145, 290, 70, 20);
	painel_Lacres.add(txtLacre22);
	
	lbLacre23.setForeground(Color.BLACK);
	lbLacre23.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre23.setBounds(115, 320, 15, 15);
	painel_Lacres.add(lbLacre23);

	txtLacre23.setForeground(Color.BLACK);
	txtLacre23.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre23.setBounds(145, 320, 70, 20);
	painel_Lacres.add(txtLacre23);
	
	lbLacre24.setForeground(Color.BLACK);
	lbLacre24.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre24.setBounds(115, 350, 15, 15);
	painel_Lacres.add(lbLacre24);

	txtLacre24.setForeground(Color.BLACK);
	txtLacre24.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre24.setBounds(145, 350, 70, 20);
	painel_Lacres.add(txtLacre24);
	
	lbLacre25.setForeground(Color.BLACK);
	lbLacre25.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre25.setBounds(225, 20, 15, 15);
	painel_Lacres.add(lbLacre25);

	txtLacre25.setForeground(Color.BLACK);
	txtLacre25.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre25.setBounds(255, 20, 70, 20);
	painel_Lacres.add(txtLacre25);
	
	lbLacre26.setForeground(Color.BLACK);
	lbLacre26.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre26.setBounds(225, 50, 15, 15);
	painel_Lacres.add(lbLacre26);

	txtLacre26.setForeground(Color.BLACK);
	txtLacre26.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre26.setBounds(255, 50, 70, 20);
	painel_Lacres.add(txtLacre26);
	
	lbLacre27.setForeground(Color.BLACK);
	lbLacre27.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre27.setBounds(225, 80, 15, 15);
	painel_Lacres.add(lbLacre27);

	txtLacre27.setForeground(Color.BLACK);
	txtLacre27.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre27.setBounds(255, 80, 70, 20);
	painel_Lacres.add(txtLacre27);
	
	lbLacre28.setForeground(Color.BLACK);
	lbLacre28.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre28.setBounds(225, 110, 15, 15);
	painel_Lacres.add(lbLacre28);

	txtLacre28.setForeground(Color.BLACK);
	txtLacre28.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre28.setBounds(255, 110, 70, 20);
	painel_Lacres.add(txtLacre28);
	
	lbLacre29.setForeground(Color.BLACK);
	lbLacre29.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre29.setBounds(225, 140, 15, 15);
	painel_Lacres.add(lbLacre29);

	txtLacre29.setForeground(Color.BLACK);
	txtLacre29.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre29.setBounds(255, 140, 70, 20);
	painel_Lacres.add(txtLacre29);
	
	lbLacre30.setForeground(Color.BLACK);
	lbLacre30.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre30.setBounds(225, 170, 15, 15);
	painel_Lacres.add(lbLacre30);

	txtLacre30.setForeground(Color.BLACK);
	txtLacre30.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre30.setBounds(255, 170, 70, 20);
	painel_Lacres.add(txtLacre30);
	
	lbLacre31.setForeground(Color.BLACK);
	lbLacre31.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre31.setBounds(225, 200, 15, 15);
	painel_Lacres.add(lbLacre31);

	txtLacre31.setForeground(Color.BLACK);
	txtLacre31.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre31.setBounds(255, 200, 70, 20);
	painel_Lacres.add(txtLacre31);
	
	lbLacre32.setForeground(Color.BLACK);
	lbLacre32.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre32.setBounds(225, 230, 15, 15);
	painel_Lacres.add(lbLacre32);

	txtLacre32.setForeground(Color.BLACK);
	txtLacre32.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre32.setBounds(255, 230, 70, 20);
	painel_Lacres.add(txtLacre32);
	
	lbLacre33.setForeground(Color.BLACK);
	lbLacre33.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre33.setBounds(225, 260, 15, 15);
	painel_Lacres.add(lbLacre33);

	txtLacre33.setForeground(Color.BLACK);
	txtLacre33.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre33.setBounds(255, 260, 70, 20);
	painel_Lacres.add(txtLacre33);
	
	lbLacre34.setForeground(Color.BLACK);
	lbLacre34.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre34.setBounds(225, 290, 15, 15);
	painel_Lacres.add(lbLacre34);

	txtLacre34.setForeground(Color.BLACK);
	txtLacre34.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre34.setBounds(255, 290, 70, 20);
	painel_Lacres.add(txtLacre34);
	
	lbLacre35.setForeground(Color.BLACK);
	lbLacre35.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre35.setBounds(225, 320, 15, 15);
	painel_Lacres.add(lbLacre35);

	txtLacre35.setForeground(Color.BLACK);
	txtLacre35.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre35.setBounds(255, 320, 70, 20);
	painel_Lacres.add(txtLacre35);
	
	lbLacre36.setForeground(Color.BLACK);
	lbLacre36.setFont(new Font("Ubuntu", Font.BOLD, 10));
	lbLacre36.setBounds(225, 350, 15, 15);
	painel_Lacres.add(lbLacre36);

	txtLacre36.setForeground(Color.BLACK);
	txtLacre36.setFont(new Font("Ubuntu", Font.BOLD, 10));
	txtLacre36.setBounds(255, 350, 70, 20);
	painel_Lacres.add(txtLacre36);
	
	
	JButton botao = new JButton("Salvar");
	botao.setBounds(10, 100, 70, 25);
	painel_produto.add(botao);
	
	
	botao.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			
			Dao dao = new Dao();
			DadosCadastro pessoa = new DadosCadastro();

			pessoa.setId(Integer.valueOf(txtCodigo.getText()));
			pessoa.setNome(txtNome.getText());
			pessoa.setEmail(txtCpf.getText());
			
			dao.salvar(pessoa);
			
		}
	});
	
	txtNome.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			
			JOptionPane.showMessageDialog(null, "Test");
			
		}
	});
	

}

}

O

Meu código que usei faz um test ai, por enquanto tá faltando por as funcionalidades para busca de dados, inserção de dados e preenchimentos de campos.

S

Código não se coloca em bloco de citação.
Código é assim:
formatacao-forum

O

Vlw.

Criado 8 de dezembro de 2020
Ultima resposta 10 de dez. de 2020
Respostas 13
Participantes 4