There is no built-in BigInteger property class in java like SimpleStringProperty class.
So, I created for you SimpleBigIntegerProperty , which can be used in the same way as the built-in property classes.
import java.math.BigInteger;
import javafx.beans.property.SimpleObjectProperty;
public class SimpleBigIntegerProperty extends SimpleObjectProperty<BigInteger>{
private static final Object DEFAULT_BEAN = null;
private static final String DEFAULT_NAME = "";
private final Object bean;
private final String name;
@Override
public Object getBean() {
return bean;
}
@Override
public String getName() {
return name;
}
public SimpleBigIntegerProperty() {
this(DEFAULT_BEAN, DEFAULT_NAME);
}
public SimpleBigIntegerProperty(BigInteger initialValue) {
this(DEFAULT_BEAN, DEFAULT_NAME, initialValue);
}
public SimpleBigIntegerProperty(Object bean, String name) {
this.bean = bean;
this.name = (name == null) ? DEFAULT_NAME : name;
}
public SimpleBigIntegerProperty(Object bean, String name, BigInteger initialValue) {
super(initialValue);
this.bean = bean;
this.name = (name == null) ? DEFAULT_NAME : name;
}
}
Example 1:
Simple example
SimpleBigIntegerProperty bigInteger = new SimpleBigIntegerProperty(BigInteger.valueOf(123456789));
System.out.println(bigInteger.getValue());
Example 2:
With the ObservableList example,
private final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jon Skeet", BigInteger.valueOf(123456789)),
new Person("Michael Brown", BigInteger.valueOf(987654321))
);
Where is the Person class (with the personβs name and age in seconds),
public class Person {
protected SimpleStringProperty personName;
protected SimpleBigIntegerProperty ageInSeconds;
public Person() {
this.personName = null;
this.ageInSeconds = null;
}
public Person(String person_name, BigInteger age_in_seconds) {
this.personName = new SimpleStringProperty(person_name);
this.ageInSeconds = new SimpleBigIntegerProperty(age_in_seconds);
}
public void setPersonName(String person_name) {
this.personName = new SimpleStringProperty(person_name);
}
public void setAgeInSeconds(BigInteger age_in_seconds) {
this.ageInSeconds = new SimpleBigIntegerProperty(age_in_seconds);
}
public String getPersonName() {
return this.personName.getValue();
}
public BigInteger getAgeInSeconds() {
return this.ageInSeconds.getValue();
}
}