NavButtonControl.java (1462B) download
1package nl.isygameclient.views;
2
3import com.jfoenix.controls.JFXButton;
4import de.jensd.fx.glyphs.materialicons.MaterialIconView;
5import javafx.beans.NamedArg;
6import javafx.fxml.FXML;
7import javafx.fxml.FXMLLoader;
8import javafx.fxml.Initializable;
9
10import java.io.IOException;
11import java.net.URL;
12import java.util.ResourceBundle;
13
14public class NavButtonControl extends JFXButton implements Initializable {
15
16 private final String glyphName;
17 private final String source;
18
19 @FXML
20 private MaterialIconView iconView;
21
22 public NavButtonControl(@NamedArg("text") String text, @NamedArg("glyphName") String glyphName, @NamedArg("source") String source) {
23 super(text);
24 this.glyphName = glyphName;
25 this.source = source;
26
27 URL url = getClass().getResource("/nl/isygameclient/views/nav-button.fxml");
28 FXMLLoader fxmlLoader = new FXMLLoader(url);
29 fxmlLoader.setRoot(this);
30 fxmlLoader.setController(this);
31
32 try {
33 fxmlLoader.load();
34 } catch (IOException e) {
35 e.printStackTrace();
36 }
37 }
38
39 @Override
40 public void initialize(URL url, ResourceBundle resourceBundle) {
41 iconView.setGlyphName(this.glyphName);
42 }
43
44 public void activate() {
45 this.getStyleClass().add("active");
46 }
47
48 public void deactivate() {
49 this.getStyleClass().remove("active");
50 }
51
52 public String getSource() {
53 return source;
54 }
55}