Pessoal, estou fazendo um sistema de locadora de veículo para desktop e estou me deparando com essa exception na tela de locação. Sei que estou tentando converter uma String nula no parseFloat na linha 319, porém não sei como resolver isso.
Exception
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
at java.base/jdk.internal.math.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.base/java.lang.Float.parseFloat(Float.java:461)
at telas.TelaAluguel.jButtonAlugarActionPerformed(TelaAluguel.java:319)
at telas.TelaAluguel.access$100(TelaAluguel.java:19)
at telas.TelaAluguel$3.actionPerformed(TelaAluguel.java:193)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6614)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6379)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4990)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4822)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2769)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4822)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
at java.desktop/java.awt.Dialog.show(Dialog.java:1070)
at java.desktop/java.awt.Component.show(Component.java:1717)
at java.desktop/java.awt.Component.setVisible(Component.java:1664)
at java.desktop/java.awt.Window.setVisible(Window.java:1028)
at java.desktop/java.awt.Dialog.setVisible(Dialog.java:1005)
at telas.TelaInicial.jButtonALUGUEISActionPerformed(TelaInicial.java:185)
at telas.TelaInicial.access$200(TelaInicial.java:14)
at telas.TelaInicial$3.actionPerformed(TelaInicial.java:82)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6614)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6379)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4990)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4822)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4548)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2769)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4822)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Tela de Locação:
package telas;
import conexao.ConexaoMySQL;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import java.util.List;
import repositorios.RepoAluguel;
import javax.swing.table.DefaultTableModel;
import negocios.Aluguel;
public class TelaAluguel extends javax.swing.JDialog {
Connection con;
Aluguel aluguel;
RepoAluguel repAluguel;
List<String> jCombobox1 = new ArrayList<>();
public TelaAluguel(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
jTextFieldCodAluguel.setEnabled(false);
habilitaCampos(false);
lerJTablelista();
}
public void lerJTablelista(){
repAluguel = new RepoAluguel();
DefaultTableModel modelo = (DefaultTableModel) jTableListaAlugados.getModel();
modelo.setNumRows(0);
for(Aluguel a : repAluguel.retornar()){
modelo.addRow(new Object[]{
//colunas da tabela
a.getCodLocacao(),
a.getCodCliente(),
a.getPlacaVeiculo(),
a.getValorDiaria(),
a.getTotalDias(),
a.getValorTotal(),
});
}
}
public void habilitaCampos(boolean valor){
jTextFieldCodCliente.setEnabled(valor);
jTextFieldPlaca.setEnabled(valor);
jTextFieldVdiaria.setEnabled(valor);
jTextFieldQtdDias.setEnabled(valor);
jTextFieldValorTotal.setEnabled(valor);
}
public void zerarCampos(){
jTextFieldCodAluguel.setText("");
jTextFieldCodCliente.setText("");
jTextFieldPlaca.setText("");
jTextFieldVdiaria.setText("");
jTextFieldQtdDias.setText("");
jTextFieldValorTotal.setText("");
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabelCodAluguel = new javax.swing.JLabel();
jTextFieldCodAluguel = new javax.swing.JTextField();
jLabelCodCliente = new javax.swing.JLabel();
jLabelPlaca = new javax.swing.JLabel();
jLabelQtdDias = new javax.swing.JLabel();
jLabelValorDiaria = new javax.swing.JLabel();
jLabelValorToTal = new javax.swing.JLabel();
jTextFieldCodCliente = new javax.swing.JTextField();
jTextFieldPlaca = new javax.swing.JTextField();
jTextFieldVdiaria = new javax.swing.JTextField();
jTextFieldQtdDias = new javax.swing.JTextField();
jTextFieldValorTotal = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTableListaAlugados = new javax.swing.JTable();
jButtonAlugar = new javax.swing.JButton();
jButtonEncerrar = new javax.swing.JButton();
jButtonCancelar = new javax.swing.JButton();
jButtonNovo = new javax.swing.JButton();
jComboBox1 = new javax.swing.JComboBox<>();
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(860, 650));
getContentPane().setLayout(null);
jLabelCodAluguel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelCodAluguel.setText("COD.Aluguel:");
getContentPane().add(jLabelCodAluguel);
jLabelCodAluguel.setBounds(170, 10, 130, 22);
getContentPane().add(jTextFieldCodAluguel);
jTextFieldCodAluguel.setBounds(300, 10, 50, 20);
jLabelCodCliente.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelCodCliente.setForeground(new java.awt.Color(255, 255, 255));
jLabelCodCliente.setText("COD.Cliente:");
getContentPane().add(jLabelCodCliente);
jLabelCodCliente.setBounds(170, 60, 120, 22);
jLabelPlaca.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelPlaca.setForeground(new java.awt.Color(255, 255, 255));
jLabelPlaca.setText("Placa:");
getContentPane().add(jLabelPlaca);
jLabelPlaca.setBounds(390, 60, 60, 22);
jLabelQtdDias.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelQtdDias.setForeground(new java.awt.Color(255, 255, 255));
jLabelQtdDias.setText("Qtd de Dias:");
getContentPane().add(jLabelQtdDias);
jLabelQtdDias.setBounds(180, 100, 120, 22);
jLabelValorDiaria.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelValorDiaria.setForeground(new java.awt.Color(255, 255, 255));
jLabelValorDiaria.setText("Valor da Diaria:");
getContentPane().add(jLabelValorDiaria);
jLabelValorDiaria.setBounds(600, 60, 150, 22);
jLabelValorToTal.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabelValorToTal.setForeground(new java.awt.Color(255, 255, 255));
jLabelValorToTal.setText("Valor Total:");
getContentPane().add(jLabelValorToTal);
jLabelValorToTal.setBounds(640, 100, 110, 22);
getContentPane().add(jTextFieldCodCliente);
jTextFieldCodCliente.setBounds(300, 60, 50, 20);
getContentPane().add(jTextFieldPlaca);
jTextFieldPlaca.setBounds(460, 60, 94, 20);
getContentPane().add(jTextFieldVdiaria);
jTextFieldVdiaria.setBounds(760, 60, 72, 20);
getContentPane().add(jTextFieldQtdDias);
jTextFieldQtdDias.setBounds(300, 100, 40, 20);
getContentPane().add(jTextFieldValorTotal);
jTextFieldValorTotal.setBounds(760, 100, 72, 20);
jTableListaAlugados.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"COD.ALUGUEL", "COD.CLIENTE", "PLACA DO VEÍCULO", "VALOR DA DIÁRIA", "QTD DIAS", "VALOR TOTAL"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTableListaAlugados.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTableListaAlugadosMouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTableListaAlugados);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(10, 201, 840, 369);
jButtonAlugar.setText("ALUGAR");
jButtonAlugar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAlugarActionPerformed(evt);
}
});
getContentPane().add(jButtonAlugar);
jButtonAlugar.setBounds(550, 580, 73, 23);
jButtonEncerrar.setText("ENCERRAR");
jButtonEncerrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonEncerrarActionPerformed(evt);
}
});
getContentPane().add(jButtonEncerrar);
jButtonEncerrar.setBounds(640, 580, 87, 23);
jButtonCancelar.setText("CANCELAR");
jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCancelarActionPerformed(evt);
}
});
getContentPane().add(jButtonCancelar);
jButtonCancelar.setBounds(750, 580, 85, 23);
jButtonNovo.setText("NOVO");
jButtonNovo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonNovoActionPerformed(evt);
}
});
getContentPane().add(jButtonNovo);
jButtonNovo.setBounds(480, 580, 61, 23);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "placa", " ", " ", " ", " ", " ", " ", " " }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
getContentPane().add(jComboBox1);
jComboBox1.setBounds(30, 80, 51, 20);
jPanel1.setBackground(new java.awt.Color(204, 204, 204));
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jLabel2.setFont(new java.awt.Font("Gill Sans MT", 1, 24)); // NOI18N
jLabel2.setForeground(new java.awt.Color(51, 51, 255));
jLabel2.setText("ALUGUEIS ATIVOS:");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(42, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
getContentPane().add(jPanel1);
jPanel1.setBounds(270, 160, 330, 40);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/imageALUGAR.png"))); // NOI18N
jLabel1.setText("jLabel1");
getContentPane().add(jLabel1);
jLabel1.setBounds(0, 0, 870, 640);
pack();
}// </editor-fold>
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
jCombobox1.add( "Blue" );
}
private void jButtonNovoActionPerformed(java.awt.event.ActionEvent evt) {
// Codigo para realizar novo aluguel
zerarCampos();
habilitaCampos(true);
jTextFieldCodCliente.requestFocus();
}
private void jButtonAlugarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO codigo botao alugar:
boolean resposta = false;
if(jTextFieldCodCliente.getText().equals("")){
JOptionPane.showMessageDialog(null, "Por favor preencha o codigo do cliente!!");
}
else if(jTextFieldPlaca.getText().equals("")){
JOptionPane.showMessageDialog(null, "Por favor preencha a placa do veiculo!");
}
else if(jTextFieldVdiaria.getText().equals("")){
JOptionPane.showMessageDialog(null, "Por favor preencha o valor da diaria!");
}
else if(jTextFieldQtdDias.getText().equals("")){
JOptionPane.showMessageDialog(null, "Por favor preencha a quantidade de dias do aluguel!");
}
/*else if(jTextFieldValorTotal.getText().equals("")){
JOptionPane.showMessageDialog(null, "Por favor preencha o Telefone!");
}*/
else
{
//preencher o objeto cliente
aluguel = new Aluguel();
repAluguel = new RepoAluguel();
aluguel.setCodCliente(Integer.parseInt(jTextFieldCodCliente.getText()));
aluguel.setPlacaVeiculo(jTextFieldPlaca.getText());
aluguel.setValorDiaria(Float.parseFloat(jTextFieldVdiaria.getText()));
aluguel.setTotalDias(Integer.parseInt(jTextFieldQtdDias.getText()));
aluguel.setValorTotal(Float.parseFloat(jTextFieldValorTotal.getText()));
con = ConexaoMySQL.getConexao();
// List<Aluguel> alugueis = new ArrayList<>();
String sql = "select placa from aluguel";
try{
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
if(jTextFieldPlaca.getText().equals(rs.getString("placa"))){
JOptionPane.showMessageDialog(null, "Este veiculo ja esta alugado!");
}
}
if(!jTextFieldPlaca.getText().equals(rs.getString("placa"))){
resposta = repAluguel.inserir(aluguel);
}
if (resposta == true){
JOptionPane.showMessageDialog(null, "Realizado com sucesso!.");
zerarCampos();
habilitaCampos(false);
lerJTablelista();
}else{
JOptionPane.showInternalMessageDialog(null, "Falha ao executar a tarefa!.");
}
}catch(SQLException ex){
//return null;
}
}
}
private void jButtonEncerrarActionPerformed(java.awt.event.ActionEvent evt) {
// encerrar aluguel
int resposta = JOptionPane.showConfirmDialog(null, "Deseja realmente devolver este veiculo?", "Aviso", JOptionPane.YES_NO_OPTION);
if (resposta == JOptionPane.YES_OPTION){
//clicou em sim
repAluguel.excluir(Integer.parseInt(jTextFieldCodAluguel.getText()));
lerJTablelista();
}else if (resposta ==JOptionPane.NO_OPTION){
//clicou em nao
}
}
private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {
// botão cancelar
zerarCampos();
habilitaCampos(false);
}
private void jTableListaAlugadosMouseClicked(java.awt.event.MouseEvent evt) {
if(jTableListaAlugados.getSelectedRow()!=-1){
jTextFieldCodAluguel.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),0).toString());
jTextFieldCodCliente.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),1).toString());
jTextFieldPlaca.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),2).toString());
jTextFieldVdiaria.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),3).toString());
jTextFieldQtdDias.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),2).toString());
jTextFieldValorTotal.setText(jTableListaAlugados.getValueAt(jTableListaAlugados. getSelectedRow(),3).toString());
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TelaAluguel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TelaAluguel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TelaAluguel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TelaAluguel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
TelaAluguel dialog = new TelaAluguel(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButtonAlugar;
private javax.swing.JButton jButtonCancelar;
private javax.swing.JButton jButtonEncerrar;
private javax.swing.JButton jButtonNovo;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabelCodAluguel;
private javax.swing.JLabel jLabelCodCliente;
private javax.swing.JLabel jLabelPlaca;
private javax.swing.JLabel jLabelQtdDias;
private javax.swing.JLabel jLabelValorDiaria;
private javax.swing.JLabel jLabelValorToTal;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTableListaAlugados;
private javax.swing.JTextField jTextFieldCodAluguel;
private javax.swing.JTextField jTextFieldCodCliente;
private javax.swing.JTextField jTextFieldPlaca;
private javax.swing.JTextField jTextFieldQtdDias;
private javax.swing.JTextField jTextFieldValorTotal;
private javax.swing.JTextField jTextFieldVdiaria;
// End of variables declaration
}
Classe Aluguel
package negocios;
public class Aluguel {
private int codLocacao;
private int codCliente;
private String placaVeiculo;
private float valorDiaria = 0.00f;
private int totalDias;
private float valorTotal = 0.00f;
public int getCodLocacao(){
return codLocacao;
}
public void setCodLocacao(int codLocacao){
this.codLocacao = codLocacao;
}
public int getCodCliente(){
return codCliente;
}
public void setCodCliente(int codCliente){
this.codCliente = codCliente;
}
public String getPlacaVeiculo(){
return placaVeiculo;
}
public void setPlacaVeiculo(String placaVeiculo){
this.placaVeiculo = placaVeiculo;
}
public float getValorDiaria(){
return valorDiaria;
}
public void setValorDiaria(float valorDiaria){
this.valorDiaria = valorDiaria;
}
public int getTotalDias(){
return totalDias;
}
public void setTotalDias(int totalDias){
this.totalDias = totalDias;
}
public float getValorTotal(){
return valorTotal;
}
public void setValorTotal(float valorTotal){
this.valorTotal = valorDiaria * totalDias;
}
}