Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BoxHanterare implements EventHandler<ActionEvent>{
- public void handle(ActionEvent event) {
- if (comboBox.getValue().toString().equalsIgnoreCase("smycke")) {
- try {
- SmyckeAlert dialog = new SmyckeAlert();
- Optional<ButtonType> result = dialog.showAndWait();
- if (result.isPresent() && result.get() == ButtonType.OK) {
- String name = dialog.getName();
- int stones = dialog.getStones();
- boolean isGold = dialog.isGold();
- Smycke smy = new Smycke(name, stones, isGold);
- värdesaker.add(smy);
- }
- }
- catch(RuntimeException e){
- Alert msg = new Alert(Alert.AlertType.ERROR);
- msg.setContentText("Fel inmatning");
- msg.showAndWait();
- }
- } else if(comboBox.getValue().toString().equalsIgnoreCase("aktie")) {
- try {
- AktieAlert dialog = new AktieAlert();
- Optional<ButtonType> result = dialog.showAndWait();
- if (result.isPresent() && result.get() == ButtonType.OK) {
- String name = dialog.getName();
- if (name.isEmpty()) {
- Alert msg = new Alert(Alert.AlertType.ERROR, "Tomt namn");
- }
- double amount = dialog.getAmount();
- double price = dialog.getPrice();
- Aktie akt = new Aktie(name, amount, price);
- värdesaker.add(akt);
- }
- }
- catch(RuntimeException e){
- Alert msg = new Alert(Alert.AlertType.ERROR);
- msg.setContentText("Fel inmatning");
- msg.showAndWait();
- }
- } else if (comboBox.getValue().toString().equalsIgnoreCase("apparat")){
- try {
- ApparatAlert dialog = new ApparatAlert();
- Optional<ButtonType> result = dialog.showAndWait();
- if (result.isPresent() && result.get() == ButtonType.OK) {
- String name = dialog.getName();
- if (name.isEmpty()) {
- Alert msg = new Alert(Alert.AlertType.ERROR, "Tomt namn");
- }
- double price = dialog.getPrice();
- double wear = dialog.getWear();
- Apparat app = new Apparat(name, price, wear);
- värdesaker.add(app);
- }
- }
- catch(RuntimeException e){
- Alert msg = new Alert(Alert.AlertType.ERROR);
- msg.setContentText("Fel inmatning");
- msg.showAndWait();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement