本文整理汇总了Java中javafx.scene.Node.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setStyle方法的具体用法?Java Node.setStyle怎么用?Java Node.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.setStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setState
import javafx.scene.Node; //导入方法依赖的package包/类
public void setState(int state)
{
// 0 is on, 1 is off
for (int index = 0; index < segments.size(); index++)
{
int maskedBit = (state >> index) & 1;
boolean isOn = (maskedBit == 0);
String color = isOn ? OFF_COLOR : ON_COLOR;
Parent segment = segments.get(index);
for (Node section : segment.getChildrenUnmodifiable())
{
section.setStyle("-fx-background-color: " + color);
}
}
}
示例2: StackedAreaChartClass
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* the constructor is responsible for initialize the chart (lower and upper buonds, name, colors)
* @param stackedAreaChart is the type of chart for battery performance
*/
public StackedAreaChartClass(StackedAreaChart stackedAreaChart){
NumberAxis yaxis = (NumberAxis) stackedAreaChart.getYAxis();
//getter and setting proprieties for y and x axes
xAxis = (NumberAxis) stackedAreaChart.getXAxis();
xAxis.setLowerBound(0);
xAxis.setUpperBound(10);
xAxis.setAutoRanging(false);
xAxis.setTickLabelsVisible(false); //hide numbers on x axis
stackedAreaChart.setVerticalGridLinesVisible(false);//hide vertical lines
stackedAreaChart.animatedProperty().setValue(false);
yaxis.setAutoRanging(false);
yaxis.setLowerBound(0);
yaxis.setUpperBound(100);
//set series of content to draw chart
series = new XYChart.Series();
series.setName("Battery level");
stackedAreaChart.getData().add(series);
//setting colors of charts
Node fill = series.getNode().lookup(".chart-series-area-fill");
fill.setStyle("-fx-fill: #fff7ad;");
Node line = series.getNode().lookup(".chart-series-area-line");
line.setStyle("-fx-stroke: #8bc34a;" +
"-fx-stroke-width: 3px;"); // set width of line
stackedAreaChart.setStyle("CHART_COLOR_1: #8bc34a;"); //color of dots
}
示例3: setFont
import javafx.scene.Node; //导入方法依赖的package包/类
public static void setFont(Node node, Font font) {
node.setStyle(setFont(node.getStyle(), font));
}
示例4: updateFont
import javafx.scene.Node; //导入方法依赖的package包/类
private static void updateFont(Node node) {
node.setStyle(
String.format("-fx-font-family: '%s'; -fx-font-size: %d;",
Options.fontFamily.get(), Options.fontSize.get()));
}