From e6fa90b4faca3463b105d42fbf1213f0ea631edc Mon Sep 17 00:00:00 2001 From: dlw-9ak-u1 <akil.alawad@stud.hs-hannover.de> Date: Thu, 8 Nov 2018 21:16:09 +0100 Subject: [PATCH] Add new file --- MenuItem.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 MenuItem.java diff --git a/MenuItem.java b/MenuItem.java new file mode 100644 index 0000000..9909810 --- /dev/null +++ b/MenuItem.java @@ -0,0 +1,47 @@ +import java.io.FileNotFoundException; + +import javafx.geometry.Pos; +import javafx.scene.effect.GaussianBlur; +import javafx.scene.layout.HBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.text.Text; + +public class MenuItem extends HBox { + private static final Font FONT = Font.font("", FontWeight.BOLD, 18); + + + private Cursor cr1 = new Cursor(),cr2 = new Cursor();; + private Text text; + private Runnable function; + + public MenuItem(String name) throws FileNotFoundException { + super(10); + + setAlignment(Pos.CENTER); + + text = new Text(name); + text.setFont(FONT); + text.setEffect(new GaussianBlur(2)); + + getChildren().addAll(cr1, text, cr2); + setActive(false); + } + + public void setActive(boolean b) { + cr1.setVisible(b); + cr2.setVisible(b); + text.setFill(b ? Color.WHITE : Color.GREEN); + } + + public void setOnActivate(Runnable r) { + function = r; + } + + public void activate() { + if (function != null) + function.run(); + } + +} \ No newline at end of file -- GitLab