import
javafx.application.Application;
import
javafx.scene.Scene;
import
javafx.scene.control.*;
import
javafx.scene.layout.*;
import
javafx.stage.Stage;
import
javafx.geometry.*;
import
javafx.scene.paint.*;
import
javafx.scene.canvas.*;
import
javafx.scene.text.*;
import
javafx.scene.Group;
import
javafx.scene.shape.*;
import
javafx.event.ActionEvent;
import
javafx.event.EventHandler;
import
javafx.collections.*;
public
class
Pos_2
extends
Application {
public
void
start(Stage stage)
{
try
{
stage.setTitle(
"Pos Class"
);
Label label =
new
Label(
"This is Pos Class Example"
);
TilePane tile_pane =
new
TilePane(label);
for
(
int
i =
1
; i <=
7
; i++) {
tile_pane.getChildren().add(
new
Button(
"Button "
+ i));
}
tile_pane.setAlignment(Pos.BASELINE_CENTER);
String pos_name[] = {
"BASELINE_CENTER"
,
"BASELINE_LEFT"
,
"BASELINE_RIGHT"
,
"BOTTOM_CENTER"
,
"BOTTOM_LEFT"
,
"BOTTOM_RIGHT"
,
"CENTER"
,
"CENTER_LEFT"
,
"CENTER_RIGHT"
,
"TOP_CENTER"
,
"TOP_LEFT"
,
"TOP_RIGHT"
};
ComboBox combo_box =
new
ComboBox(FXCollections.observableArrayList(pos_name));
EventHandler<ActionEvent> event =
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent e)
{
tile_pane.setAlignment(Pos.valueOf(
(String)combo_box.getValue()));
}
};
combo_box.setOnAction(event);
VBox vbox =
new
VBox(
30
, combo_box, tile_pane);
vbox.setAlignment(Pos.CENTER);
Scene scene =
new
Scene(vbox,
400
,
300
);
stage.setScene(scene);
stage.show();
}
catch
(Exception e) {
System.out.println(e.getMessage());
}
}
public
static
void
main(String args[])
{
launch(args);
}
}