Basisklasse mit allen vier Beispielen: |
Basis.java |
errorBox mit Alert |
import javafx.scene.control.Dialog; import javafx.scene.control.Alert;
public static void errorBox( String message, String title) { Dialog alert = new Alert(Alert.AlertType.ERROR,message); alert.setTitle(title); alert.setHeaderText(title); alert.setResizable(true); alert.show(); } // ErrorBox |
readString |
// javafx.scene.control.TextInputDialog
public static String insertString(String message, String title, String vorgabe) { TextInputDialog dialog = new TextInputDialog(vorgabe); dialog.setTitle(title); dialog.setContentText(message); dialog.setHeaderText(title); dialog.setResizable(true); java.util.Optional<String> result = dialog.showAndWait();
if (result.isPresent()) { return (String)result.get(); } else { return null; } } |
converstString2Double |
public static double getDoubleNumber(String str_zahl) { try { double zahl = Double.parseDouble(str_zahl); return zahl; } catch (NumberFormatException e) { return Double.NaN; } // try } // getDoubleNumber
Abfrage:
if (!Double.isNaN(pktNeu)) { listePunkte.set(index,pktNeu); } |
convertString2Integer |
public static Integer getIntegerNumber(String str_zahl) { try { int zahl = Integer.parseInt(str_zahl); return zahl; } catch (NumberFormatException e) { return null; } // try } // getIntegerNumber |