diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-03-31 11:19:32 +0200 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-03-31 11:19:32 +0200 |
| commit | e53db140f27e405f4e541ad23b737836db36b2ad (patch) | |
| tree | 8646193cd16ff1b4d0c1b95a4b7c8f2f18d21468 /src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java | |
| parent | bafe58a20a02e79b2af61c7b179e7d9ff68b8a4f (diff) | |
| download | Java2-e53db140f27e405f4e541ad23b737836db36b2ad.tar.gz Java2-e53db140f27e405f4e541ad23b737836db36b2ad.zip | |
Exercise No.2.1 with extra MainBorderPain
Diffstat (limited to 'src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java')
| -rw-r--r-- | src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java b/src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java new file mode 100644 index 0000000..c70e1b3 --- /dev/null +++ b/src/de/fhswf/in/inf/java2/aufgabe02/MainBorderPane.java @@ -0,0 +1,54 @@ +/** + * Class MainBorderPain. + */ + +package de.fhswf.in.inf.java2.aufgabe02; + +import java.util.Map; + +import javafx.scene.control.Button; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +/** + * Dynamically creates the buttons and labels. + * + * @author $Author: $ + * @version $Revision: $, $Date: $ UTC + */ +public class MainBorderPane extends BorderPane +{ + + StackPane labelPane = new StackPane(); + + VBox buttonPane = new VBox(); + + /** + * Creates buttons with text from key and the button creates a label with + * name from value. + * + * @param names + * The Map with the key value mappings. + * + */ + public MainBorderPane(Map<String, String> names) + { + if (names == null) + { + throw new IllegalArgumentException("labels can't be null."); + } + + Button tmp; + for (String name : names.keySet()) + { + tmp = new Button(name); + tmp.setOnAction(new CardChangeEvent(labelPane.getChildren(), names + .get(name))); + buttonPane.getChildren().add(tmp); + } + + setLeft(buttonPane); + setCenter(labelPane); + } +} |
