public HudPane() { FXMLLoader view = new FXMLLoader(Main.class.getResource("/view/ConfigHudComponent.fxml")); view.setRoot(this); view.setController(this); try { view.load(); } catch (IOException e) { e.printStackTrace(); } txtWid.setMaxMin(0, 1); txtHei.setMaxMin(0, 1); txtRelY.setMaxMin(0, 1); txtRelX.setMaxMin(0, 1); setHandler(); }
public void init() { if (hud != null) { if (hud.getRelativeY() >= 0) { txtRelY.setText(hud.getRelativeY() + ""); } if (hud.getRelativeX() >= 0) { txtRelX.setText(hud.getRelativeX() + ""); } if (hud.getRelativeHeight() > 0) { txtHei.setText(hud.getRelativeHeight() + ""); } if (hud.getRelativeWidth() > 0) { txtWid.setText(hud.getRelativeWidth() + ""); } } }
private void setHandler() { txtRelX .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { hud.setRelativeX(txtRelX.getValue()); } } }); txtRelY .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { hud.setRelativeY(txtRelY.getValue()); } } }); txtWid .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { hud.setRelativeWidth(txtWid.getValue()); } } }); txtHei .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!newValue) { hud.setRelativeHeight(txtHei.getValue()); } } }); }