game-client

Play TicTacToe and Reversi
Log | Files | Refs

NavButtonControl.java (1462B)


      1 package nl.isygameclient.views;
      2 
      3 import com.jfoenix.controls.JFXButton;
      4 import de.jensd.fx.glyphs.materialicons.MaterialIconView;
      5 import javafx.beans.NamedArg;
      6 import javafx.fxml.FXML;
      7 import javafx.fxml.FXMLLoader;
      8 import javafx.fxml.Initializable;
      9 
     10 import java.io.IOException;
     11 import java.net.URL;
     12 import java.util.ResourceBundle;
     13 
     14 public 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 }