javafx.scene.layout.Region.setBackground()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中javafx.scene.layout.Region.setBackground方法的一些代码示例,展示了Region.setBackground的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region.setBackground方法的具体详情如下:
包路径:javafx.scene.layout.Region
类名称:Region
方法名:setBackground

Region.setBackground介绍

暂无

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

public static void updateBackground(Background newBackground, Region nodeToUpdate, Paint fill) {
  if (newBackground != null && !newBackground.getFills().isEmpty()) {
    final BackgroundFill[] fills = new BackgroundFill[newBackground.getFills().size()];
    for (int i = 0; i < newBackground.getFills().size(); i++) {
      BackgroundFill bf = newBackground.getFills().get(i);
      fills[i] = new BackgroundFill(fill, bf.getRadii(), bf.getInsets());
    }
    nodeToUpdate.setBackground(new Background(fills));
  }
}

代码示例来源:origin: stackoverflow.com

TextArea textArea = new TextArea("I have an ugly white background :-(");
 // we don't use lambdas to create the change listener since we use
 // the instance twice via 'this' (see *)
 textArea.skinProperty().addListener(new ChangeListener<Skin<?>>() {
   @Override
   public void changed(
    ObservableValue<? extends Skin<?>> ov, Skin<?> t, Skin<?> t1) {
     if (t1 != null && t1.getNode() instanceof Region) {
       Region r = (Region) t1.getNode();
       r.setBackground(Background.EMPTY);
       r.getChildrenUnmodifiable().stream().
           filter(n -> n instanceof Region).
           map(n -> (Region) n).
           forEach(n -> n.setBackground(Background.EMPTY));
       r.getChildrenUnmodifiable().stream().
           filter(n -> n instanceof Control).
           map(n -> (Control) n).
           forEach(c -> c.skinProperty().addListener(this)); // *
     }
   }
 });

代码示例来源:origin: jfoenixadmin/JFoenix

private void init() {
  setClip(clip);
  clip.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(2), Insets.EMPTY)));
  backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(getBackground(), clip));
}

代码示例来源:origin: jfoenixadmin/JFoenix

/**
   * {@inheritDoc}
   */
  @Override
  protected void interpolate(double frac) {
    if (start == null) {
      starting();
    }
    Color newColor = start.interpolate(end, frac);
    if (Color.TRANSPARENT.equals(start)) {
      newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity());
    }
    region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets)));
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

.getFills()
  .get(0);
((Region) glyphDetailViewer.sizeSlider.lookup(lookup)).setBackground(new Background(new BackgroundFill(
  Color.valueOf(webColor),
  fill.getRadii(),

代码示例来源:origin: jfoenixadmin/JFoenix

public void initialize() {
  track = new StackPane();
  track.getStyleClass().setAll("track");
  bar = new StackPane();
  bar.getStyleClass().setAll("bar");
  secondaryBar = new StackPane();
  secondaryBar.getStyleClass().setAll("secondary-bar");
  clip = new Region();
  clip.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
  bar.backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(bar.getBackground(), clip));
  getChildren().setAll(track, secondaryBar, bar);
}

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
  super.layoutChildren(x, y, w, h);
  final double height = getSkinnable().getHeight();
  linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
  errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
  linesWrapper.updateLabelFloatLayout();
  if (invalid) {
    invalid = false;
    // set the default background of text area viewport to white
    Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
    viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
      CornerRadii.EMPTY,
      Insets.EMPTY)));
    // reapply css of scroll pane in case set by the user
    viewPort.applyCss();
    errorContainer.invalid(w);
    // focus
    linesWrapper.invalid();
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
  super.layoutChildren(x, y, w, h);
  final double height = getSkinnable().getHeight();
  linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
  errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
  linesWrapper.updateLabelFloatLayout();
  if (invalid) {
    invalid = false;
    // set the default background of text area viewport to white
    Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
    viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
      CornerRadii.EMPTY,
      Insets.EMPTY)));
    // reapply css of scroll pane in case set by the user
    viewPort.applyCss();
    errorContainer.invalid(w);
    // focus
    linesWrapper.invalid();
  }
}

代码示例来源:origin: jfoenixadmin/JFoenix

clip.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(3), Insets.EMPTY)));
backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(getBackground(), clip));

代码示例来源:origin: jfoenixadmin/JFoenix

CornerRadii.EMPTY,
  Insets.EMPTY)));
((Region) tabs.lookup(".tab-header-background")).setBackground(new Background(new BackgroundFill(
  curvedColorPicker.getColor(curvedColorPicker.getSelectedIndex()),
  CornerRadii.EMPTY,

代码示例来源:origin: com.jfoenix/jfoenix

public static void updateBackground(Background newBackground, Region nodeToUpdate, Paint fill) {
  if (newBackground != null && !newBackground.getFills().isEmpty()) {
    final BackgroundFill[] fills = new BackgroundFill[newBackground.getFills().size()];
    for (int i = 0; i < newBackground.getFills().size(); i++) {
      BackgroundFill bf = newBackground.getFills().get(i);
      fills[i] = new BackgroundFill(fill, bf.getRadii(), bf.getInsets());
    }
    nodeToUpdate.setBackground(new Background(fills));
  }
}

代码示例来源:origin: com.jfoenix/jfoenix

private void updateArrow(JFXTimePicker picker) {
  ((Region) arrowButton.getChildren().get(0)).setBackground(new Background(
    new BackgroundFill(picker.getDefaultColor(), null, null)));
  ((JFXTextField) getEditor()).setFocusColor(jfxTimePicker.getDefaultColor());
}

代码示例来源:origin: com.jfoenix/jfoenix

private void updateArrow(JFXDatePicker datePicker) {
  ((Region) arrowButton.getChildren().get(0)).setBackground(new Background(
    new BackgroundFill(datePicker.getDefaultColor(), null, null)));
  ((JFXTextField) getEditor()).setFocusColor(jfxDatePicker.getDefaultColor());
}

代码示例来源:origin: com.jfoenix/jfoenix

private void init() {
  setClip(clip);
  clip.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(2), Insets.EMPTY)));
  backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(getBackground(), clip));
}

代码示例来源:origin: com.jfoenix/jfoenix

/**
   * {@inheritDoc}
   */
  @Override
  protected void interpolate(double frac) {
    if (start == null) {
      starting();
    }
    Color newColor = start.interpolate(end, frac);
    if (Color.TRANSPARENT.equals(start)) {
      newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity());
    }
    region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets)));
  }
}

代码示例来源:origin: com.jfoenix/jfoenix

protected void initialize() {
  track = new StackPane();
  track.getStyleClass().setAll("track");
  bar = new StackPane();
  bar.getStyleClass().setAll("bar");
  secondaryBar = new StackPane();
  secondaryBar.getStyleClass().setAll("secondary-bar");
  clip = new Region();
  clip.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
  bar.backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(bar.getBackground(), clip));
  getChildren().setAll(track, secondaryBar, bar);
}

代码示例来源:origin: com.jfoenix/jfoenix

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
  super.layoutChildren(x, y, w, h);
  final double height = getSkinnable().getHeight();
  linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
  errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
  linesWrapper.updateLabelFloatLayout();
  if (invalid) {
    invalid = false;
    // set the default background of text area viewport to white
    Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
    viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
      CornerRadii.EMPTY,
      Insets.EMPTY)));
    // reapply css of scroll pane in case set by the user
    viewPort.applyCss();
    errorContainer.invalid(w);
    // focus
    linesWrapper.invalid();
  }
}

代码示例来源:origin: com.jfoenix/jfoenix

clip.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(3), Insets.EMPTY)));
backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(getBackground(), clip));

代码示例来源:origin: com.jfoenix/jfoenix

CornerRadii.EMPTY,
  Insets.EMPTY)));
((Region) tabs.lookup(".tab-header-background")).setBackground(new Background(new BackgroundFill(
  curvedColorPicker.getColor(curvedColorPicker.getSelectedIndex()),
  CornerRadii.EMPTY,

相关文章

微信公众号

最新文章

更多