本文整理汇总了Java中javafx.scene.control.Label.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setStyle方法的具体用法?Java Label.setStyle怎么用?Java Label.setStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void initializeLabel() {
LoggerFacade.getDefault().trace(this.getClass(), "Initialize Label"); // NOI18N
lSign = new Label();
lSign.setPadding(DEFAULT_PADDING);
lSign.setMinWidth(26.0d);
lSign.setStyle("-fx-background-color:POWDERBLUE"); // NOI18N
lSign.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
final Term term = new Term();
term.setTitle("" + System.currentTimeMillis()); // NOI18N
this.onActionAddTerm(term);
}
});
super.getChildren().add(0, lSign);
}
示例2: MyNode
import javafx.scene.control.Label; //导入方法依赖的package包/类
public MyNode(String name) {
text = new Label(name);
text.setStyle("-fx-border-color:black; -fx-padding:3px;");
text.setLayoutX(4);
text.setLayoutY(2);
getChildren().addAll(text);
}
示例3: display
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static void display(String title, String message)
{
Stage window= new Stage();
window.initModality(Modality.APPLICATION_MODAL);
//window.setAlwaysOnTop(true);
window.getIcons().add(new Image("/pic/slogo.png"));
window.setTitle(title);
Label label= new Label();
label.setText(message);
label.setStyle("-fx-font-size:14px;");
ImageView imageView = new ImageView(ICON);
imageView.setFitWidth(40);
imageView.setFitHeight(40);
Label labelimage = new Label("",imageView);
// two buttons
Button okbtn= new Button("Ok");
okbtn.setOnAction(e -> {
answer= false;
window.close();
});
okbtn.setId("red");
HBox hbox= new HBox(10);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setPadding(new Insets(10,5,10,5));
hbox.getChildren().addAll(labelimage,label);
VBox layout= new VBox(15);
layout.setAlignment(Pos.CENTER_RIGHT);
layout.setPadding(new Insets(10,5,10,5));
layout.getChildren().addAll(hbox,okbtn);
layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
Scene scene= new Scene(layout);
scene.getStylesheets().add(ErrorMessage.class.getResource("confirm.css").toExternalForm());
window.setScene(scene);
window.setResizable(false);
window.showAndWait();
}
示例4: addMessageToErrorPane
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static void addMessageToErrorPane(String message){
Label l = new Label(message);
l.setFont(Font.font(settingsFontSize-5));
l.setStyle("-fx-text-fill: white;");
l.setTranslateY(fehlerMeldungen.getChildren().size()*20);
if(fehlerMeldungen.getChildren().size() >= 10){
Platform.runLater(() -> {
fehlerMeldungen.getChildren().remove(0);
fehlerMeldungen.getChildren().add(l);
for(int i = 0; i < fehlerMeldungen.getChildren().size(); i++){
fehlerMeldungen.getChildren().get(i).setTranslateY(i*20);
}
});
} else{
Platform.runLater(() -> fehlerMeldungen.getChildren().add(l));
}
}
示例5: sold
import javafx.scene.control.Label; //导入方法依赖的package包/类
protected void sold(String item, short amount, short profit){
Main.store.playPurchaseSound();
Gang.setMoney(Gang.getMoney() + profit);
Button button = new Button("Back");
Label label = new Label("You sold "+amount+" "+item+" for $"+profit);
label.setFont(new Font(20));
label.setStyle("-fx-text-fill: white;");
VBox stackPane = new VBox();
stackPane.setStyle("-fx-background-color: #cf1020");
stackPane.setPadding(new Insets(20,20,20,20));
stackPane.getChildren().addAll(label,button);
Scene scene = new Scene(stackPane);
button.setOnAction(e -> Main.getAlertWindow().setScene(Main.getSellScene()));
Main.getAlertWindow().setScene(scene);
if (!(Main.getAlertWindow().isShowing())) Main.getAlertWindow().showAndWait();
}
示例6: display
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static void display(String title, String message)
{
Stage window= new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setAlwaysOnTop(true);
window.getIcons().add(new Image("/pic/slogo.png"));
window.setTitle(title);
Label label= new Label();
label.setText(message);
label.setStyle("-fx-font-size:14px;");
ImageView imageView = new ImageView(ICON);
imageView.setFitWidth(40);
imageView.setFitHeight(40);
Label labelimage = new Label("",imageView);
// two buttons
Button okbtn= new Button("Ok");
okbtn.setOnAction(e -> {
answer= false;
window.close();
});
okbtn.setId("blue");
HBox hbox= new HBox(10);
hbox.setAlignment(Pos.CENTER_LEFT);
hbox.setPadding(new Insets(10,5,10,5));
hbox.getChildren().addAll(labelimage,label);
VBox layout= new VBox(15);
layout.setAlignment(Pos.CENTER_RIGHT);
layout.setPadding(new Insets(10,5,10,5));
layout.getChildren().addAll(hbox,okbtn);
layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
Scene scene= new Scene(layout);
window.setScene(scene);
scene.getStylesheets().add(SuccessMessage.class.getResource("confirm.css").toExternalForm());
window.setResizable(false);
window.showAndWait();
}
示例7: specialPurchase
import javafx.scene.control.Label; //导入方法依赖的package包/类
protected void specialPurchase(String item){
Button button = new Button("Ok");
Label label = new Label("Purchased: " + item);
label.setFont(new Font(20));
label.setStyle("-fx-text-fill: white;");
VBox stackPane = new VBox();
stackPane.setStyle("-fx-background-color: #cf1020");
stackPane.setPadding(new Insets(20,20,20,20));
stackPane.getChildren().addAll(label,button);
Scene scene = new Scene(stackPane);
// Determining what scene to go back too
if (!(Main.getAlertWindow().isShowing())) button.setOnAction(e -> Main.getAlertWindow().close());
else if (Main.getAlertWindow().getScene() == Main.getDealerScene()) button.setOnAction(e -> Main.getAlertWindow().setScene(Main.getDealerScene()));
else if (Main.getAlertWindow().getScene() == Main.getGunStoreScene()) button.setOnAction(e -> Main.getAlertWindow().setScene(Main.getGunStoreScene()));
Main.getAlertWindow().setScene(scene);
Main.getAlertWindow().setTitle("PURCHASED");
if (!(Main.getAlertWindow().isShowing())) Main.getAlertWindow().showAndWait();
}
示例8: openLogWindow
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void openLogWindow(){
Stage stage = new Stage();
//Label l = new Label("Während deiner aktuellen Sitzung sind Fehler aufgetreten. Durch einen Klick auf Weiter werden deine Log-Datei und deine Anregungen anonym hochgeladen.");
Label l = new Label("Während deiner aktuellen Sitzung sind Fehler aufgetreten. Durch einen Klick auf Weiter wird deine Log-Datei anonym hochgeladen.");
l.setStyle("-fx-text-fill: white");
l.setFont(Font.font(settingsFontSize));
l.setWrapText(true);
l.setMaxWidth(450);
l.setTranslateY(25);
l.setTranslateX(25);
/*TextField ta = new TextField();
ta.setFont(Font.font(settingsFontSize-3));
ta.setTranslateX(25);
ta.setTranslateY(125);
ta.setPrefWidth(450);
ta.setPrefHeight(100);*/
Button bno = new Button("Abbrechen");
bno.setFont(Font.font(settingsFontSize));
bno.setOnAction(e -> stage.close());
bno.setTranslateX(250);
bno.setTranslateY(150);
Button byes = new Button("Weiter");
byes.setFont(Font.font(settingsFontSize));
byes.setTranslateX(150);
byes.setTranslateY(150);
byes.setOnAction(e -> {
byes.setDisable(true);
bno.setDisable(true);
Runnable r = () -> {
sendLogFile(l);
};
new Thread(r).start();
});
Pane p = new Pane(l, byes, bno);
p.setStyle("-fx-background-color: #303030");
p.setMinSize(500,200);
p.setMaxSize(500, 200);
Scene s = new Scene(p,500,200);
stage.setScene(s);
stage.setTitle("Log-Datei senden?");
stage.setAlwaysOnTop(true);
stage.show();
}
示例9: createBox
import javafx.scene.control.Label; //导入方法依赖的package包/类
private Node createBox(Cursor cursor) {
Label label = new Label(cursor.toString());
label.setAlignment(Pos.CENTER);
label.setPrefSize(85, 85);
label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
label.setCursor(cursor);
return label;
}
示例10: createIconLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static Label createIconLabel(GlyphIcons icon, String iconSize, String text, ContentDisplay contentDisplay, Paint colour, String style, Pos alignment, int width)
{
Text iconLabel = GlyphsDude.createIcon(icon, iconSize);
iconLabel.setFill(colour);
Label label = new Label(text);
label.setTextFill(colour);
label.setStyle(style);
label.setGraphic(iconLabel);
label.setContentDisplay(contentDisplay);
label.setMinWidth(width);
label.setMaxWidth(width);
label.setAlignment(alignment);
return label;
}
示例11: CustomNodeSample
import javafx.scene.control.Label; //导入方法依赖的package包/类
public CustomNodeSample() {
VBox vbox = new VBox();
MyNode myNode = new MyNode("MyNode");
MyNode parent = new MyNode("Parent");
Polygon arrow = createUMLArrow();
Label extend = new Label("<<extends>>");
extend.setStyle("-fx-padding: 0 0 0 -1em;");
vbox.getChildren().addAll(parent,arrow,myNode);
vbox.setAlignment(Pos.CENTER);
HBox hbox = new HBox();
hbox.setAlignment(Pos.CENTER);
hbox.setPadding(new Insets(10));
hbox.getChildren().addAll(vbox,extend);
getChildren().addAll(hbox);
}
示例12: paceSetterMethod
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
*
* Creates, and sets the scene to one that allows the player(s) to set the pace
*
*/
protected static void paceSetterMethod(){
VBox PaceLayout = new VBox(10);
Label label = new Label("Choose a speed");
Button Slowbtn = new Button("Slow pace");
Button ModerateSpeedbtn = new Button("Moderate pace");
Button Fastbtn = new Button("Fast pace");
label.setStyle("-fx-text-fill: purple;");
label.setFont(new Font(20));
PaceLayout.setStyle("-fx-background-color: black");
Slowbtn.setOnAction(e -> {
Gang.setPace(5);
TravelController.animationDuration = 30;
getMenuWindow().setScene(menuScene);
});
ModerateSpeedbtn.setOnAction(e -> {
Gang.setPace(10);
TravelController.animationDuration = 15;
getMenuWindow().setScene(menuScene);
});
Fastbtn.setOnAction(e -> {
Gang.setPace(15);
TravelController.animationDuration = 10;
getMenuWindow().setScene(menuScene);
});
PaceLayout.setPadding(new Insets(20,20,20,20));
PaceLayout.getChildren().addAll(label,Slowbtn,ModerateSpeedbtn,Fastbtn);
setPaceScene(new Scene(PaceLayout,320,200));
}
示例13: ToggleButtonSample
import javafx.scene.control.Label; //导入方法依赖的package包/类
public ToggleButtonSample() {
// create label to show result of selected toggle button
final Label label = new Label();
label.setStyle("-fx-font-size: 2em;");
// create 3 toggle buttons and a toogle group for them
final ToggleButton tb1 = new ToggleButton("Cat");
final ToggleButton tb2 = new ToggleButton("Dog");
final ToggleButton tb3 = new ToggleButton("Horse");
ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
@Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
if(selectedToggle!=null) {
label.setText(((ToggleButton) selectedToggle).getText());
}
else {
label.setText("...");
}
}
});
// select the first button to start with
group.selectToggle(tb1);
// add buttons and label to grid and set their positions
GridPane.setConstraints(tb1,0,0);
GridPane.setConstraints(tb2,1,0);
GridPane.setConstraints(tb3,2,0);
GridPane.setConstraints(label,0,1,3,1);
GridPane grid = new GridPane();
grid.setVgap(20);
grid.setHgap(10);
getChildren().add(grid);
grid.getChildren().addAll(tb1, tb2, tb3, label);
}
示例14: addClickableListElement
import javafx.scene.control.Label; //导入方法依赖的package包/类
public void addClickableListElement(final String s, 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.setRipplerFill(Color.GREY_BLUE.getColor(Color.Intensity.I300));
rippler.setOnMouseEntered(event -> {
// 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 -> {
// 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 we do not do this, the method below will be called twice
if (!(event.getTarget() instanceof StackPane)) return;
mouseEventConsumer.accept(event);
});
list.getChildren().add(rippler);
}
示例15: display
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static boolean display(String title, String message)
{
Stage window= new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.getIcons().add(new Image("/pic/slogo.png"));
window.setTitle(title);
//window.setAlwaysOnTop(true);
Label label= new Label();
label.setText(message);
label.setStyle("-fx-font-size:14px;");
label.setAlignment(Pos.CENTER_LEFT);
ImageView imageView = new ImageView(ICON);
imageView.setFitWidth(35);
imageView.setFitHeight(35);
Label labelimage = new Label("",imageView);
// two buttons
Button yesbtn= new Button("Yes");
yesbtn.setId("red");
Button nobtn= new Button("No");
nobtn.setId("green");
yesbtn.setOnAction(e -> {
answer= true;
window.close();
});
nobtn.setOnAction(e -> {
answer= false;
window.close();
});
HBox hbox= new HBox(10);
hbox.setAlignment(Pos.CENTER_RIGHT);
hbox.setPadding(new Insets(0,5,0,5));
hbox.getChildren().addAll(yesbtn, nobtn);
HBox layout= new HBox(5);
layout.setPadding(new Insets(10,5,10,5));
layout.getChildren().addAll(labelimage,label);
VBox layout2= new VBox(10);
layout2.setPadding(new Insets(10,10,10,10));
layout2.getChildren().addAll(layout, hbox);
layout2.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
Scene scene= new Scene(layout2);
scene.getStylesheets().add(Confirmation.class.getResource("confirm.css").toExternalForm());
window.setScene(scene);
window.setResizable(false);
window.showAndWait();
return answer;
}