/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com;
import java.util.ArrayList;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author Ramon
*/
public class Veiculo {
private final SimpleStringProperty Marca = new SimpleStringProperty();
private final SimpleStringProperty Modelo = new SimpleStringProperty();
private final SimpleStringProperty Cor = new SimpleStringProperty();
private final SimpleStringProperty Placa = new SimpleStringProperty();
private final SimpleIntegerProperty idveiculo = new SimpleIntegerProperty();
private final ArrayList < Veiculo > listaVeiculo;
public Veiculo(String Marca, String Modelo, String Cor, String Placa) {
this.Marca.set(Marca);
this.Modelo.set(Modelo);
this.Cor.set(Cor);
this.Placa.set(Placa);
listaVeiculo = new ArrayList();
}
public String getMusica() {
return Marca.get();
}
public String getAlbum() {
return Modelo.get();
}
public String getArtista() {
return Cor.get();
}
public String getGenero() {
return Placa.get();
}
public int getClas() {
return idveiculo.get();
}
public void setMusica(String Marca) {
this.Marca.set(Marca);
}
public void setAlbum(String Modelo) {
this.Modelo.set(Modelo);
}
public void setArtista(String Cor) {
this.Cor.set(Cor);
}
public void setGenero(String Placa) {
this.Placa.set(Placa);
}
public void setClas(int idveiculo) {
this.idveiculo.set(idveiculo);
}
public void adM(Veiculo v) {
listaVeiculo.add(v);
}
}
FXML Controller where in my opinion the error occurs
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
/**
* FXML Controller class
*
* @author Ramon
*/
public class ExibirVeiculosDentroDaCasaController implements Initializable {@
FXML private TableColumn clMarca;@
FXML private TableColumn clModelo;@
FXML private TableColumn clCor;@
FXML private TableColumn clPlaca;@
FXML private TableView < Veiculo > tbVeiculo;
private ObservableList < Veiculo > listVeiculo;
/**
* Initializes the controller class.
* @param url
* @param rb
*/
@
Override
public void initialize(URL url, ResourceBundle rb) {
listVeiculo = FXCollections.observableArrayList();
assert tbVeiculo != null: "fx:id=\"tableview\" was not injected: check your FXML file 'UserMaster.fxml'.";
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bdestacionamento?zeroDateTimeBehavior=convertToNull", "root", "");
java.sql.Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT marca,modelo,cor,placa FROM veiculo,registro WHERE registro.status =1 and registro.veiculo_idveiculo=veiculo.idveiculo ;");
while (rs.next()) {
Veiculo v = new Veiculo("1", "2", "3", "4");
v.setMusica(rs.getString("marca"));
v.setAlbum(rs.getString("modelo"));
v.setArtista(rs.getString("cor"));
v.setGenero(rs.getString("placa"));
System.out.println(rs.getString("marca"));
System.out.println(rs.getString("modelo"));
System.out.println(rs.getString("cor"));
System.out.println(rs.getString("placa"));
listVeiculo.add(v);
}
clMarca.setCellValueFactory(new PropertyValueFactory("Marca"));
clModelo.setCellValueFactory(new PropertyValueFactory("Modelo"));
clCor.setCellValueFactory(new PropertyValueFactory("Cor"));
clPlaca.setCellValueFactory(new PropertyValueFactory("Placa"));
tbVeiculo.setItems(null);// Ja pensei que poderia ser isso mas nao é
tbVeiculo.setItems(listVeiculo);
} catch (SQLException ex) {
Logger.getLogger(ExibirVeiculosDentroDaCasaController.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(ExibirVeiculosDentroDaCasaController.class.getName()).log(Level.SEVERE, null, ex);
}
}@
FXML private void btAction() {
}
}
Does anyone have any notions or tips?
As you can see up to the third line of the table to click, it kind of "filled" these lines, but nothing is displayed