mirror of
https://codeberg.org/qg-info-unterricht/zpg-graphentester.git
synced 2026-03-25 04:58:24 +01:00
First Commit (Fobi)
This commit is contained in:
commit
2bff291a51
336 changed files with 88781 additions and 0 deletions
43
imp/NumberField.java
Normal file
43
imp/NumberField.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package imp;
|
||||
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class NumberField extends TextField {
|
||||
|
||||
@Override public void replaceText(int start, int end, String text) {
|
||||
if (text.matches("[0-9.]") || text == "") {
|
||||
super.replaceText(start, end, text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void replaceSelection(String text) {
|
||||
if (text.matches("[0-9.]") || text == "") {
|
||||
super.replaceSelection(text);
|
||||
}
|
||||
}
|
||||
|
||||
public double getDoubleValue() {
|
||||
try{
|
||||
return Double.parseDouble(this.getText());
|
||||
} catch(Exception e) {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIntValue() {
|
||||
try{
|
||||
return Integer.parseInt(this.getText());
|
||||
} catch(Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(double v) {
|
||||
setText(""+v);
|
||||
}
|
||||
|
||||
public void setValue(int v) {
|
||||
setText(""+v);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue