-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuItem.java
More file actions
55 lines (49 loc) · 1.33 KB
/
MenuItem.java
File metadata and controls
55 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package game;
import javafx.animation.ScaleTransition;
import javafx.geometry.Pos;
import javafx.scene.effect.Glow;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* menu buttons
*
* @author FerrariHD
*
*/
public class MenuItem extends StackPane {
public MenuItem(String name) {
Glow glow = new Glow();
glow.setLevel(1.0);
Rectangle bg = new Rectangle(280, 34, Color.TRANSPARENT);
bg.setEffect(glow);
bg.setOpacity(1);
bg.setArcHeight(7.5);
bg.setArcWidth(7.5);
bg.setStrokeWidth(1.1);
bg.setStroke(Color.WHITE);
Text text = new Text(name);
text.setFill(Color.WHITE);
text.setFont(Font.font("Candara", FontWeight.MEDIUM, 18));
setAlignment(Pos.CENTER);
getChildren().addAll(bg, text);
ScaleTransition tr = new ScaleTransition(Duration.millis(25), bg);
setOnMouseEntered(event -> {
bg.setStroke(Color.YELLOW);
tr.setToX(1.075);
tr.setToY(1.2);
tr.play();
});
setOnMouseExited(event -> {
tr.stop();
tr.setToX(1);
tr.setToY(1);
tr.play();
bg.setStroke(Color.WHITE);
});
}
}