本文整理汇总了Java中javafx.scene.layout.HBox.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java HBox.setPadding方法的具体用法?Java HBox.setPadding怎么用?Java HBox.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.HBox
的用法示例。
在下文中一共展示了HBox.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
Scene scene = new Scene(new Group());
scene.setFill(Color.ALICEBLUE);
stage.setScene(scene);
stage.show();
stage.setTitle("ChoiceBox Sample");
stage.setWidth(300);
stage.setHeight(200);
label.setFont(Font.font("Arial", 25));
label.setLayoutX(40);
final String[] greetings = new String[]{"Hello", "Hola", "Привет", "你好",
"こんにちは"};
final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList(
"English", "Español", "Русский", "简体中文", "日本語")
);
cb.getSelectionModel().selectedIndexProperty().addListener(
(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) -> {
label.setText(greetings[new_val.intValue()]);
});
cb.setTooltip(new Tooltip("Select the language"));
cb.setValue("English");
HBox hb = new HBox();
hb.getChildren().addAll(cb, label);
hb.setSpacing(30);
hb.setAlignment(Pos.CENTER);
hb.setPadding(new Insets(10, 0, 0, 10));
((Group) scene.getRoot()).getChildren().add(hb);
}
示例2: display
import javafx.scene.layout.HBox; //导入方法依赖的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();
}
示例3: Mesazhi
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public Mesazhi(String titulli, String titulli_msg, String mesazhi){
stage.setTitle(titulli);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
HBox root = new HBox(15);
VBox sub_root = new VBox(10);
HBox btn = new HBox();
Text ttl = new Text(titulli_msg);
ttl.setFont(Font.font(16));
Button btnOk = new Button("Ne rregull");
btn.getChildren().add(btnOk);
btn.setAlignment(Pos.CENTER_RIGHT);
btnOk.setOnAction(e -> stage.close());
btnOk.setOnKeyPressed(e -> {
if (e.getCode().equals(KeyCode.ENTER)) stage.close();
else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close();
});
root.setPadding(new Insets(20));
sub_root.getChildren().addAll(ttl, new Label(mesazhi), btn);
if (titulli == "Gabim")
root.getChildren().add(new ImageView(new Image("/sample/foto/error.png")));
else if (titulli == "Sukses")
root.getChildren().add(new ImageView(new Image("/sample/foto/success.png")));
else if (titulli == "Informacion")
root.getChildren().add(new ImageView(new Image("/sample/foto/question.png")));
else if (titulli == "Info")
root.getChildren().add(new ImageView(new Image("/sample/foto/info.png")));
root.getChildren().add(sub_root);
root.setAlignment(Pos.TOP_CENTER);
Scene scene = new Scene(root, 450, 150);
scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
示例4: constructContainer
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
bottom = new HBox(50);
bottom.setAlignment(Pos.CENTER);
bottom.setMaxWidth(300);
bottom.setPadding(new Insets(20,50,150,280));
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(100,20,20,20));
btnOwnDMO = new AppButton("Eigenes DMO");
btnForeignDMO = new AppButton("Fremdes DMO");
back = new BackButton(getFXController(), "Zur�ck");
home = new HomeButton(getFXController());
AllFields.getChildren().addAll(btnOwnDMO, btnForeignDMO, back, home);
bottom.getChildren().addAll(back, home);
bp.setCenter(AllFields);
bp.setBottom(bottom);
btnOwnDMO.setOnAction(e -> getFXController().showView("savedownloaddoorowndmoview"));
btnForeignDMO.setOnAction(e -> getFXController().showView("savedownloadstackforeigndmoview"));
back.setOnAction(e -> getFXController().showView("serverdoorview"));
return bp;
}
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:35,代码来源:SaveDownloaddoorOnServerDialogView.java
示例5: constructContainer
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
bottom = new HBox(50);
bottom.setAlignment(Pos.CENTER);
bottom.setMaxWidth(300);
bottom.setPadding(new Insets(20,50,150,280));
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(100,20,20,20));
btnLocal = new AppButton("lokal speichern");
btnServer = new AppButton("auf dem Server speichern");
back = new BackButton(getFXController(), "Zur�ck");
home = new HomeButton(getFXController());
AllFields.getChildren().addAll(btnLocal, btnServer);
bottom.getChildren().addAll(back, home);
bp.setCenter(AllFields);
bp.setBottom(bottom);
btnLocal.setOnAction(e -> getFXController().showView("savedownloadstacklocalview"));
btnServer.setOnAction(e -> getFXController().showView("savedownloaddooronserverdialogview"));
back.setOnAction(e -> getFXController().showView("serverdoorview"));
return bp;
}
示例6: initCenter
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private void initCenter() {
center = new TabPane();
addTab("Processos", initTabProcesses());
addTab("Recursos", initTabResources());
HBox centerContainer = new HBox(center);
centerContainer.setPadding(new Insets(0, 10, 10, 10));
centerContainer.setBackground(new Background(new BackgroundFill(
Color.gray(0.865), CornerRadii.EMPTY, Insets.EMPTY)));
layoutPane.setCenter(centerContainer);
}
示例7: initializeDisplayControls
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private Node initializeDisplayControls(){
VBox simplecontrols = new VBox();
simplecontrols.setSpacing(5.0);
simplecontrols.setPadding(new Insets(0.0, 0.0, 0.0, 5.0));
simplecontrols.setAlignment(Pos.TOP_CENTER);
controlsSimple_Pane = simplecontrols;
VBox graphiccontrols = new VBox();
graphiccontrols.setSpacing(10.0);
graphiccontrols.setAlignment(Pos.TOP_CENTER);
//SplitPane graphiccontrols = new SplitPane();
//graphiccontrols.setOrientation(Orientation.VERTICAL);
graphiccontrols.setPadding(new Insets(5.0, 5.0, 0.0, 0.0));
controlsGraphic_Pane = graphiccontrols;
SplitPane controlsPane = new SplitPane();
controlsPane.setOrientation(Orientation.HORIZONTAL);
controlsPane.getItems().addAll(graphiccontrols, simplecontrols);
controlsPane.setMinSize(380.0, 300.0);
HBox root = new HBox();
root.setAlignment(Pos.TOP_CENTER);
root.setPadding(new Insets(5.0, 0.0, 5.0, 5.0));
root.setMinWidth(380.0);
root.getChildren().addAll(controlsPane);
return root;
}
示例8: CustomNodeSample
import javafx.scene.layout.HBox; //导入方法依赖的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);
}
示例9: loadPropertyViewer
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private void loadPropertyViewer(){
keysBox = new ComboBox<String>();
keysBox.setPrefWidth(150);
valField = new TextField();
valField.setPrefWidth(150);
final Button save = new Button("Save"), newProp = new Button("New"),
delete = new Button("Delete");
save.setDisable(true);
delete.setDisable(true);
keysBox.getItems().add("");
String[] keys = getKeys();
keysBox.getItems().addAll(keys);
keysBox.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue)->{
local = true;
if(newValue.intValue() != 0){
cProp = props.get(newValue.intValue() - 1);
valField.setText(cProp.getValue());
delete.setDisable(false);
}else {
valField.setText("");
delete.setDisable(true);
}
local = false;
save.setDisable(true);
});
valField.textProperty().addListener((observable, oldValue, newValue)->{
if(!local && keysBox.getSelectionModel().getSelectedIndex() > 0)
save.setDisable(false);
});
delete.setOnAction((e)->{
int i = keysBox.getSelectionModel().getSelectedIndex();
if(i != 0){
keysBox.getItems().remove(i);
props.get(i - 1).remove();
props.remove(i - 1);
}
keysBox.getSelectionModel().select(i - 1);
});
save.setOnAction((e)->{
String newVal = valField.getText();
if(!newProp(cProp, newVal))
FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
save.setDisable(true);
});
newProp.setOnAction((e)->{
Property prop = PropertyViewer.showPropertyCreator(this);
if(prop != null){
props.add(prop);
keysBox.getItems().add(prop.getName());
}
});
VBox viewerNode = new VBox();
viewerNode.getChildren().addAll(keysBox, valField);
viewerNode.setSpacing(10);
viewerNode.setAlignment(Pos.CENTER);
viewerNode.setPadding(new Insets(10, 10, 10, 10));
HBox buttonNode = new HBox();
buttonNode.getChildren().addAll(save, newProp, delete);
buttonNode.setSpacing(10);
buttonNode.setAlignment(Pos.CENTER_RIGHT);
buttonNode.setPadding(new Insets(0, 5, 5, 0));
BorderPane pane = new BorderPane();
pane.setBottom(buttonNode);
pane.setCenter(viewerNode);
setScene(new Scene(pane, 200, 200));
}
示例10: loadPropertyCreator
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private void loadPropertyCreator(){
nameField = new TextField();
nameField.setPrefWidth(150);
valField = new TextField();
valField.setPrefWidth(150);
valField.setDisable(true);
final ComboBox<Property.Type> typeBox = new ComboBox<Property.Type>();
typeBox.setPrefWidth(150);
typeBox.getItems().addAll(Property.Type.values());
final Button save = new Button("Save"), cancel = new Button("Cancel");
save.setDisable(true);
nameField.textProperty().addListener((observable, oldValue, newValue)->{
if(valField.isDisabled() && !newValue.equals(""))
valField.setDisable(false);
});
valField.textProperty().addListener((observable, oldValue, newValue)->{
if(!valField.getText().equals(""))
save.setDisable(false);
else save.setDisable(true);
});
save.setOnAction((e)->{
String newVal = valField.getText();
String keyName = nameField.getText();
Property.Type t = typeBox.getValue();
System.out.println(t);
System.out.println(newVal);
cProp = new Property(keyName, t);
if(!newProp(cProp, newVal))
FlashFXUtils.showErrorDialog(this, "Error", "Value is incompatible with property type");
else close();
});
cancel.setOnAction((e)->{
cProp = null;
close();
});
VBox viewerNode = new VBox();
viewerNode.getChildren().addAll(nameField, valField, typeBox);
viewerNode.setSpacing(10);
viewerNode.setAlignment(Pos.CENTER);
viewerNode.setPadding(new Insets(10, 10, 10, 10));
HBox buttonNode = new HBox();
buttonNode.getChildren().addAll(save, cancel);
buttonNode.setSpacing(10);
buttonNode.setAlignment(Pos.CENTER_RIGHT);
buttonNode.setPadding(new Insets(0, 5, 5, 0));
BorderPane pane = new BorderPane();
pane.setBottom(buttonNode);
pane.setCenter(viewerNode);
setScene(new Scene(pane, 200, 200));
}
示例11: SpielFeld
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
/**
* Konstruktormethode zur Einrichtung des Spielfeldes.
*/
public SpielFeld() {
// spiel enthaelt die Spiellogik
spiel = new Spiel(this);
// Arrays fuer Auswahl-Buttons und die Spielsteine
button = new Button[7];
field = new Label[42];
// Bilder fuer Auswahl-Button, Spieler1, Spieler2 und "leere Steine"
user = new Image("user.gif");
red = new Image("red.gif");
green = new Image("green.gif");
gray = new Image("grau.gif");
// Spieler1 ist rot, Spieler2 gruen
ROT = 1;
GRUEN = 2;
// Initialisierung des Labels am oberen Rand
display = new Label("Rot beginnt!");
labelBox = new HBox(display);
labelBox.setAlignment(Pos.CENTER);
labelBox.setStyle("-fx-background-color: red;");
this.setTop(labelBox);
// Initialisierung des Spielfeldes in der Mitte
gridPanel = new GridPane();
gridPanel.setAlignment(Pos.CENTER);
gridPanel.setStyle("-fx-background-color: black;");
gridPanel.setPadding(new Insets(3));
// Hinzufuegen der Auswahlknoepfe mit Event-Handlern
for (int i = 0; i < 7; i++) {
button[i] = new Button("", new ImageView(user));
button[i].setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
button[i].addEventHandler(ActionEvent.ACTION, e -> spiel.waehleSpalte(e));
gridPanel.add(button[i], i, 0);
}
// Hinzufuegen der "Spielsteine"
for (int i = 0; i < 42; i++) {
field[i] = new Label("", new ImageView(gray));
field[i].setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
field[i].setStyle("-fx-border-color: white;");
gridPanel.add(field[i], i % 7, i / 7 + 1);
}
this.setCenter(gridPanel);
// Initialisierung der "Menue-Buttons" am unteren Rand
buttonBox = new HBox(20);
buttonBox.setAlignment(Pos.CENTER);
buttonBox.setPadding(new Insets(5));
neuesSpiel = new Button("Neues Spiel");
neuesSpiel.addEventHandler(ActionEvent.ACTION, e -> spiel.clean());
hilfe = new Button("Hilfe");
hilfe.addEventHandler(ActionEvent.ACTION, e -> new HilfeDialog().showAndWait());
buttonBox.getChildren().addAll(neuesSpiel, hilfe);
this.setBottom(buttonBox);
}
示例12: createHorizontalBox
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public static HBox createHorizontalBox(double width, double height, Insets insets)
{
HBox box = createHorizontalBox(width, height);
box.setPadding(insets);
return box;
}
示例13: createTopBar
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public HBox createTopBar()
{
HBox hbox = new HBox();
hbox.setPadding(new Insets(15, 15, 15, 15));
hbox.setSpacing(10);
hbox.setStyle("-fx-background-color: lightsteelblue;");
ObservableList<Node> buttons = hbox.getChildren();
Set<Node> buttonEffectsSet = new HashSet<>();
Node runButton = new ImageView("toolbar_run.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(runButton);
buttonEffectsSet.add(runButton);
Node stepButton = new ImageView("toolbar_step.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(stepButton);
buttonEffectsSet.add(stepButton);
Node resetButton = new ImageView("toolbar_reset.png");
runButton.setOnMouseClicked((event) -> {
// TODO: Attach to Backend
});
buttons.add(resetButton);
buttonEffectsSet.add(resetButton);
buttonEffectsSet.forEach(EmulationWindow::setButtonEffect);
Label cycleLabel = new Label();
cycleLabel.setText("Cycle: ");
cycleLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(cycleLabel);
Label cycleLabelCount = new Label();
cycleLabelCount.setText("0");
cycleLabelCount.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(cycleLabelCount);
Label stepLabel = new Label();
stepLabel.setText("Step: ");
stepLabel.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(stepLabel);
Label stepLabelCount = new Label();
stepLabelCount.setText("0");
stepLabelCount.setFont(Font.font("Arial", FontWeight.NORMAL, 18));
buttons.add(stepLabelCount);
Label simModeState = new Label();
simModeState.setText("Sim Mode");
simModeState.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
buttons.add(simModeState);
Node simModeImage = new ImageView("sim_mode_on.png");
buttons.add(simModeImage);
return hbox;
}
示例14: customizeControlePaneLayout
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public void customizeControlePaneLayout(HBox controlPane) {
controlPane.setPadding(new Insets(15, 12, 15, 12));
controlPane.setSpacing(10);
}
示例15: start
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public void start(Stage primaryStage) {
primaryStage.setTitle("Animal Images");
hboxFirst=new HBox();
hboxFirst.setPadding(new Insets(15, 12, 15, 12));
hboxFirst.setSpacing(10);
sceneFirst = new Scene(hboxFirst);
createGame(sceneFirst, hboxFirst);
primaryStage.setScene(sceneFirst);
primaryStage.show();
}