本文整理匯總了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()));
}