-4

HERE IS THE CODE

@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 
}

HERE ARE THE REST OF THE 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);
}

This is an update "How do I get a label to add its value to an integer field or column in a table view in javafx". Please how do I solve this issue?

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190

1 Answers1

0

How about:

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