Java Reference
In-Depth Information
The getter and setter methods for property
values and a getter for property itself are provided
in the class, but omitted in the UML diagram for brevity.
javafx.scene.control.Labeled
-alignment: ObjectProperty<Pos>
-contentDisplay:
ObjectProperty<ContentDisplay>
-graphic: ObjectProperty<Node>
-graphicTextGap: DoubleProperty
-textFill: ObjectProperty<Paint>
-text: StringProperty
-underline: BooleanProperty
-wrapText: BooleanProperty
Specifies the alignment of the text and node in the labeled.
Specifies the position of the node relative to the text using the constants
TOP,BOTTOM,LEFT , and RIGHT defined in ContentDisplay .
A graphic for the labeled.
The gap between the graphic and the text.
The paint used to fill the text.
A text for the labeled.
Whether text should be underlined.
Whether text should be wrapped if the text exceeds the width.
F IGURE 16.2
Labeled defines common properties for Label , Button , CheckBox , and RadioButton .
javafx.scene.control.Labeled
javafx.scene.control.Label
+Label()
+Label(text: String)
+Label(text: String, graphic: Node)
Creates an empty label.
Creates a label with the specified text.
Creates a label with the specified text and graphic.
F IGURE 16.3
Label is created to display a text or a node, or both.
6 import javafx.scene.image.Image;
7 import javafx.scene.image.ImageView;
8 import javafx.scene.layout.HBox;
9 import javafx.scene.layout.StackPane;
10 import javafx.scene.paint.Color;
11 import javafx.scene.shape.Circle;
12 import javafx.scene.shape.Rectangle;
13 import javafx.scene.shape.Ellipse;
14
15 public class LabelWithGraphic extends Application {
16 @Override // Override the start method in the Application class
17 public void start(Stage primaryStage) {
18 ImageView us = new ImageView( new Image( "image/us.gif" ));
19 Label lb1 = new Label( "US\n50 States" , us);
20 lb1.setStyle( "-fx-border-color: green; -fx-border-width: 2" );
21 lb1.setContentDisplay(ContentDisplay.BOTTOM);
22 lb1.setTextFill(Color.RED);
23
24 Label lb2 = new Label( "Circle" , new Circle( 50 , 50 , 25 ));
25 lb2.setContentDisplay(ContentDisplay.TOP);
26 lb2.setTextFill(Color.ORANGE);
27
28 Label lb3 = new Label( "Retangle" , new Rectangle( 10 , 10 , 50 , 25 ));
29 lb3.setContentDisplay(ContentDisplay.RIGHT);
30
31 Label lb4 = new Label( "Ellipse" , new Ellipse( 50 , 50 , 50 , 25 ));
32 lb4.setContentDisplay(ContentDisplay.LEFT);
33
create a label
set node position
create a label
set node position
create a label
create a label
 
Search WWH ::




Custom Search