本文整理匯總了Java中javafx.scene.control.Label.setOpacity方法的典型用法代碼示例。如果您正苦於以下問題:Java Label.setOpacity方法的具體用法?Java Label.setOpacity怎麽用?Java Label.setOpacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setOpacity方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TimeScaleViewSkin
import javafx.scene.control.Label; //導入方法依賴的package包/類
public TimeScaleViewSkin(T view) {
super(view);
LocalTime time = LocalTime.of(1, 0);
for (int i = 1; i < 24; i++) {
Label label = new Label(time.format(formatter));
label.setManaged(false);
label.setMaxWidth(Double.MAX_VALUE);
label.setAlignment(Pos.CENTER_RIGHT);
label.getStyleClass().add("time-label"); //$NON-NLS-1$
label.setTextOverrun(OverrunStyle.CLIP);
labels.add(label);
getChildren().add(label);
time = time.plusHours(1);
}
currentTimeLabel = new Label();
currentTimeLabel.getStyleClass().add("current-time-label"); //$NON-NLS-1$
currentTimeLabel.setManaged(false);
currentTimeLabel.setMaxWidth(Double.MAX_VALUE);
currentTimeLabel.setAlignment(Pos.CENTER_RIGHT);
currentTimeLabel.setOpacity(0);
currentTimeLabel.setTextOverrun(OverrunStyle.CLIP);
currentTimeLabel.visibleProperty().bind(view.enableCurrentTimeMarkerProperty());
getChildren().add(currentTimeLabel);
updateCurrentTimeMarkerVisibility();
view.showCurrentTimeMarkerProperty().addListener(
it -> updateCurrentTimeMarkerVisibility());
setupCurrentTimeMarkerSupport();
updateShowMarkers();
}
示例2: start
import javafx.scene.control.Label; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) {
double[] values = new double[]{50,166,200,106,94,211,172,133,132,185,152,131,158,180,172,314,262,160};
//---->Default graph using plotter<----
LineGraph graph = new LineGraph(400,200, Theme.TRAFFIC);
graph.setInterval(20);
//Populating the graph
for (double value : values) {
graph.addValue(value);
}
graph.render(LineGraph.Render.ALL);
StackPane background = new StackPane();
background.setPrefHeight(300);
background.setPrefWidth(600);
background.setStyle("-fx-background-color: radial-gradient(center 50% 50%, radius 100%, #2a367f, #1f2756)");
background.getChildren().add(graph);
StackPane.setAlignment(graph, Pos.CENTER);
StackPane axis = new StackPane();
axis.setMaxSize(500,50);
Line divider = new Line(50,0,550,0);
divider.setStroke(Color.WHITE);
divider.setOpacity(0.3);
axis.getChildren().add(divider);
StackPane.setAlignment(divider,Pos.CENTER);
Label time1 = new Label("8am");
Label time2 = new Label("5pm");
time1.setTextFill(Color.WHITE);
time2.setTextFill(Color.WHITE);
time1.setOpacity(0.5);
time2.setOpacity(0.5);
time1.setFont(Font.font("Calibri",16));
time2.setFont(Font.font("Calibri",16));
axis.getChildren().addAll(time1,time2);
StackPane.setAlignment(time1,Pos.BOTTOM_LEFT);
StackPane.setMargin(time1, new Insets(0,0,0,30));
StackPane.setAlignment(time2, Pos.BOTTOM_RIGHT);
StackPane.setMargin(time2, new Insets(0,30,0,0));
background.getChildren().add(axis);
StackPane.setAlignment(axis, Pos.BOTTOM_CENTER);
StackPane.setMargin(axis, new Insets(0,0,40,0));
primaryStage.setScene(new Scene(background));
primaryStage.setTitle("Traffic");
primaryStage.show();
}
示例3: createStateLabels
import javafx.scene.control.Label; //導入方法依賴的package包/類
private void createStateLabels() {
Group overlay = map.getOverlayGroup();
for(String state: Region.ALL_STATES) {
Node stateNode = map.lookup("#"+state);
if (stateNode != null) {
Label label = new Label("+10");
label.getStyleClass().add("heatmap-label");
label.setTextAlignment(TextAlignment.CENTER);
label.setAlignment(Pos.CENTER);
label.setManaged(false);
label.setOpacity(0);
label.setVisible(false);
Bounds stateBounds = stateNode.getBoundsInParent();
if ("DE".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(),
stateBounds.getWidth()+50, stateBounds.getHeight());
} else if ("VT".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("NH".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("MA".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("RI".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(),
stateBounds.getWidth()+40, stateBounds.getHeight());
} else if ("ID".equals(state)) {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60,
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("MI".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("FL".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else if ("LA".equals(state)) {
label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
} else {
label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(),
stateBounds.getWidth(), stateBounds.getHeight());
}
stateLabelMap.put(state, label);
overlay.getChildren().add(label);
}
}
}
示例4: addClickableAndDisableableListElement
import javafx.scene.control.Label; //導入方法依賴的package包/類
public void addClickableAndDisableableListElement(final String s, final ObservableBooleanValue isDisabled, final Consumer<MouseEvent> mouseEventConsumer) {
final Label label = new Label(s);
label.setStyle("-fx-padding: 8 16 8 16;");
label.getStyleClass().add("body2");
label.setMinWidth(width);
final JFXRippler rippler = new JFXRippler(label);
rippler.setOnMouseEntered(event -> {
if (isDisabled.get()) return;
// Set the background to a light grey
label.setBackground(new Background(new BackgroundFill(
Color.GREY.getColor(Color.Intensity.I200),
CornerRadii.EMPTY,
Insets.EMPTY
)));
canIShowSubMenu.set(false);
});
rippler.setOnMouseExited(event -> {
if (isDisabled.get()) return;
// Set the background to be transparent
label.setBackground(new Background(new BackgroundFill(
TRANSPARENT,
CornerRadii.EMPTY,
Insets.EMPTY
)));
});
// When the rippler is pressed, run the provided consumer.
rippler.setOnMousePressed(event -> {
if (isDisabled.get()) {
event.consume();
return;
}
// If we do not do this, the method below will be called twice
if (!(event.getTarget() instanceof StackPane)) return;
mouseEventConsumer.accept(event);
});
final Consumer<Boolean> updateTransparency = (disabled) -> {
if (disabled) {
rippler.setRipplerFill(WHITE);
label.setOpacity(0.5);
} else {
rippler.setOpacity(1);
rippler.setRipplerFill(Color.GREY_BLUE.getColor(Color.Intensity.I300));
label.setOpacity(1);
}
};
isDisabled.addListener((obs, oldDisabled, newDisabled) -> updateTransparency.accept(newDisabled));
updateTransparency.accept(isDisabled.get());
list.getChildren().add(rippler);
}