The problem here is that I wanna make sure that the user doesn't enter any strings or text especially that I need to enter his choice into a database later so I don't things to get messed up in the database's part, here is part of code which is the view I wish to use the textview with restricted Integers (specifically the amount am field). PS: I'm still new to both JavaFX and TornadoFX so hope this doesn't sound like a rather silly question.
My Code:
package com.company.view
import javafx.beans.property.SimpleIntegerProperty
import javafx.scene.control.CheckBox
import tornadofx.*
import javafx.scene.control.TextField
import javafx.util.converter.NumberStringConverter
import java.sql.Connection
class Add: View() {
override val root = Form()
private val mainMenu: MainMenu by inject()
private var cname: TextField by singleAssign()
private var address: TextField by singleAssign()
private var sname: TextField by singleAssign()
private var ch: CheckBox by singleAssign()
private var am: TextField by singleAssign()
var conn: Connection?= mainMenu.conn
init {
with(root) {
vbox(30.0) {
fieldset("Enter Your Info below") {
field("Enter The Customer's Name") {
cname = textfield()
}
field("Enter the Customer's address") {
address = textfield()
}
field("Enter Bought Stock's Name") {
sname = textfield()
}
field("Do you wish to pay now?") {
ch = checkbox()
}
field("Enter the amount you wish to buy"){
am = textfield()
}
button("Submit")
{
setOnAction {
addPayment(cname.text, address.text, sname.text, ch.isSelected, am.text)
}
}
}
}
}
}
private fun addPayment(cusName: String, caddress: String, stname: String, che: Boolean,am: String){
//required code for inserting into the database here.
}
}