-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabelProperties2.java
More file actions
65 lines (56 loc) · 2.58 KB
/
LabelProperties2.java
File metadata and controls
65 lines (56 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import javafx.geometry.Pos;
public class LabelProperties2 extends Application {
@Override
public void start(Stage primaryStage) {
VBox root = new VBox(10);
root.setPadding(new Insets(20));
ImageView imageView = new ImageView(new Image("file:1.png"));
imageView.setFitWidth(50);
imageView.setFitHeight(50);
Label demoLabel = new Label("Ace of Spades", imageView);
ComboBox<ContentDisplay> contentDisplayComboBox = new ComboBox<>();
contentDisplayComboBox.getItems().addAll(ContentDisplay.values());
contentDisplayComboBox.setValue(ContentDisplay.LEFT); // default value
contentDisplayComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
demoLabel.setContentDisplay(newValue);
});
Slider gapSlider = new Slider(0, 50, 5);
gapSlider.setShowTickLabels(true);
gapSlider.setShowTickMarks(true);
gapSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
demoLabel.setGraphicTextGap(newValue.doubleValue());
});
ComboBox<Pos> alignmentComboBox = new ComboBox<>();
alignmentComboBox.getItems().addAll(Pos.values());
alignmentComboBox.setValue(Pos.CENTER_LEFT); // default value
alignmentComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
demoLabel.setAlignment(newValue);
});
ComboBox<TextAlignment> textAlignmentComboBox = new ComboBox<>();
textAlignmentComboBox.getItems().addAll(TextAlignment.values());
textAlignmentComboBox.setValue(TextAlignment.LEFT); // default value
textAlignmentComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
demoLabel.setTextAlignment(newValue);
});
root.getChildren().addAll(demoLabel, contentDisplayComboBox, gapSlider, alignmentComboBox, textAlignmentComboBox);
Scene scene = new Scene(root, 400, 400);
primaryStage.setTitle("Label Properties Demo");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}