2017-03-17 4 views
-4

VOICI LE CODEComment puis-je obtenir une étiquette d'ajouter sa valeur à un champ entier ou d'une colonne dans une vue de table dans JavaFX

@FXML 
private void OK01(ActionEvent event) 
{ 
rImg20.setVisible(false); 
tv.setVisible(true); 


String combo022 = combo02.getValue().toString(); 

del01.setVisible(true); 

data.add(new InvoiceEntry(
(String) combo01.getValue(), 
combo022, 
(String) combo03.getValue(), 
(String) combo04.getValue(), 

(Integer)prCombo01.getText()));  //Here is the problem, i cant get this label to 
add its value to the integer column (price) of the table 
} 

VOICI LE RESTE DES CODES: InvoiceEntry.java

import javafx.beans.property.SimpleIntegerProperty; 
import javafx.beans.property.SimpleStringProperty; 
import javafx.scene.control.TableColumn; 

public class InvoiceEntry 
{ 
private final SimpleStringProperty clothe; 
private final SimpleStringProperty pattern; 
private final SimpleStringProperty designer; 
private final SimpleStringProperty color; 
private final SimpleIntegerProperty price; 

public InvoiceEntry(
String clothe, 
String pattern, 
String designer, 
String color, 
Integer price 
) 

{ 
this.clothe = new SimpleStringProperty(clothe); 
this.pattern = new SimpleStringProperty(pattern); 
this.designer = new SimpleStringProperty(designer); 
this.color = new SimpleStringProperty(color); 
this.price = new SimpleIntegerProperty(price); 
} 

public String getClothe() 
{ 
return clothe.get(); 
} 

public void setClothe(String iName) 
{ 
this.clothe.set(iName); 
} 

public String getPattern() 
{ 
return pattern.get(); 
} 

public void setPattern(String iName) 
{ 
this.pattern.set(iName); 
} 


public String getDesigner() 
{ 
return designer.get(); 
} 

public void setDesigner(String iName) 
{ 
this.designer.set(iName); 
} 

public String getColor() 
{ 
return color.get(); 
} 

public void setColor(String iName) 
{ 
this.color.set(iName); 
} 

public Integer getPrice() 
{ 
return price.get(); 
} 

public void setPrice(Integer iName) 
{ 
this.price.set(iName); 
} 
} 

FXMLCONTROLLER.java

@FXML 
private TableView tv; 
@FXML 
private TableColumn<InvoiceEntry, String> clothe; 
@FXML 
private TableColumn<InvoiceEntry, String> pattern; 
@FXML 
private TableColumn<InvoiceEntry, String> designer; 
@FXML 
private TableColumn<InvoiceEntry, String> color; 
@FXML 
private TableColumn<InvoiceEntry, Integer> price; 
@FXML 
private ComboBox combo01; 
@FXML 
private ColorPicker combo02; 
@FXML 
private ComboBox combo03; 
@FXML 
private ComboBox combo04; 
@FXML 
private Label prCombo01; 
private ObservableList<InvoiceEntry> data; 

@Override 
public void initialize(URL url, ResourceBundle rb) 
{ 
    clothe.setCellValueFactory(
    new PropertyValueFactory<InvoiceEntry, String>("clothe")); 

    pattern.setCellValueFactory(
    new PropertyValueFactory<InvoiceEntry, String>("pattern")); 

    designer.setCellValueFactory(
    new PropertyValueFactory<InvoiceEntry, String>("designer")); 

    color.setCellValueFactory(
    new PropertyValueFactory<InvoiceEntry, String>("color")); 

    price.setCellValueFactory(
    new PropertyValueFactory<InvoiceEntry, Integer>("price")); 

    data = FXCollections.observableArrayList(
    new InvoiceEntry("", "", "", "", 0)); 
    tv.setItems(data); 
} 

Ceci est une mise à jour « Comment puis-je obtenir un label pour ajouter son va renvoyer à un champ entier ou une colonne dans une vue de table dans javafx ". S'il vous plaît comment puis-je résoudre ce problème?

+1

https://stackoverflow.com/help/mcve – klutt

Répondre

0

Que diriez-vous:

data.add(new InvoiceEntry(
(String) combo01.getValue(), 
(String) combo02.getValue(), 
(String) combo03.getValue(), 
(String) combo04.getValue(), 
Integer.parseInt(Combo01.getText()))); 
+0

essayé, mais ça n'a pas marché .... Je vous remercie ... merci – user7728803