I'm trying to make the TextField for my JSpinner uneditable in netbeans so the user can only use the up and down button to change the int value in the textfield of the JSpinner, how can I do this? an alternative would be for me to only allow int values to be typed into the box and not double values, right now if the user input is 21,5 then 215 points are added to that certain "Elevhem" in the database.
(the name of my JSpinner is antalPoang)
if (Validering.isPositivtSpinner(antalPoang)) {
try {
String elevhemsNamn = (String) namnElevhem.getSelectedItem();
int points = (int) antalPoang.getValue();
String query = "UPDATE ELEVHEM SET HUSPOANG = HUSPOANG + " + points + " WHERE ELEVHEMSNAMN ='" + elevhemsNamn +"'";
if (namnElevhem.getSelectedItem().equals("Gryffindor")) {
db.update(query);
ImageIcon icon = new ImageIcon("Gryffindor.png");
JOptionPane.showMessageDialog(null, "Poängen har lagts till", " ", JOptionPane.INFORMATION_MESSAGE, icon);
antalPoang.setValue(0);
} else if (namnElevhem.getSelectedItem().equals("Ravenclaw")) {
db.update(query);
ImageIcon icon = new ImageIcon("Ravenclaw.png");
JOptionPane.showMessageDialog(null, "Poängen har lagts till", " ", JOptionPane.INFORMATION_MESSAGE, icon);
antalPoang.setValue(0);
} else if (namnElevhem.getSelectedItem().equals("Slytherin")) {
db.update(query);
ImageIcon icon = new ImageIcon("Slytherin.png");
JOptionPane.showMessageDialog(null, "Poängen har lagts till", " ", JOptionPane.INFORMATION_MESSAGE, icon);
antalPoang.setValue(0);
} else if (namnElevhem.getSelectedItem().equals("Hufflepuff")) {
db.update(query);
ImageIcon icon = new ImageIcon("Hufflepuff.png");
JOptionPane.showMessageDialog(null, "Poängen har lagts till", " ", JOptionPane.INFORMATION_MESSAGE, icon);
antalPoang.setValue(0);
}
} catch (InfException e) {
JOptionPane.showMessageDialog(null, "Något blev fel");
}
}