本文整理汇总了Java中javafx.scene.layout.HBox.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Java HBox.setStyle方法的具体用法?Java HBox.setStyle怎么用?Java HBox.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.HBox
的用法示例。
在下文中一共展示了HBox.setStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageBar
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private Node getMessageBar(VBox vbox) {
HBox hb = new HBox(10);
hb.setPrefHeight(32);
hb.setStyle("-fx-padding: 0 5px 0 5px; -fx-background-color: " + _message_bg + ";");
CheckBox cb = new CheckBox("Do Not Show Again");
cb.setStyle("-fx-text-fill: " + _message_fg + ";-fx-fill: " + _message_fg + ";");
Text b = FXUIUtils.getIconAsText("close");
b.setOnMouseClicked((e) -> {
JSONObject preferences = Preferences.instance().getSection("display");
preferences.put("_doNotShowMessage", cb.isSelected());
Preferences.instance().save("display");
vbox.getChildren().remove(0);
});
Text t = new Text(_message);
hb.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(t, Priority.ALWAYS);
t.setStyle("-fx-fill: " + _message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold; -fx-font-family: Tahoma;");
b.setStyle("-fx-fill: " + _message_fg + "; -fx-font-size: 14px; -fx-font-weight:bold;");
Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
hb.getChildren().addAll(t, spacer, b);
return hb;
}
示例2: initComponents
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
/**
* Initializes the components.
*/
protected void initComponents() {
// Declare roles
saveButton.setDefaultButton(true);
cancelButton.setCancelButton(true);
// Init behavior
saveButton.setOnAction(event -> {
handleSave(event);
event.consume();
});
cancelButton.setOnAction(event -> {
handleCancel(event);
event.consume();
});
// Init layout of components
HBox btnBox = new HBox();
btnBox.getChildren().addAll(saveButton, cancelButton);
getChildren().add(btnBox);
setRightAnchor(btnBox, 0d);
btnBox.setStyle("-fx-spacing: inherit;-fx-padding: inherit");
}
示例3: wrap
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public Node wrap(Node node) {
HBox box = new HBox();
box.setStyle("-fx-padding: 100px;");
box.setAlignment(Pos.CENTER);
box.setFillHeight(false);
StackPane stackPane = new StackPane();
stackPane.setStyle(
"-fx-background-color: white; -fx-border-color: gray; -fx-border-width: .25px; -fx-padding: 0 20 0 20;");
box.getChildren().add(stackPane);
stackPane.getChildren().add(node);
stackPane.setEffect(new Reflection());
return box;
}
示例4: wrap
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
protected Node wrap(Node node) {
HBox box = new HBox();
box.setStyle("-fx-padding: 100px;");
box.setAlignment(Pos.CENTER);
box.setFillHeight(false);
StackPane stackPane = new StackPane();
stackPane.setStyle(
"-fx-background-color: white; -fx-border-color: gray; -fx-border-width: .25px; -fx-padding: 0 20 0 20;");
box.getChildren().add(stackPane);
stackPane.getChildren().add(node);
stackPane.setEffect(new Reflection());
return box;
}
示例5: wrap
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
protected Node wrap(Node node) {
TimeRangeView field = (TimeRangeView) node;
Label label = new Label("Range: " + field.getStartDate() + " to " + field.getEndDate());
label.setMaxHeight(Double.MAX_VALUE);
field.startDateProperty().addListener(it -> label.setText("Range: " + field.getStartDate() + " to " + field.getEndDate()));
field.endDateProperty().addListener(it -> label.setText("Range: " + field.getStartDate() + " to " + field.getEndDate()));
VBox box2 = new VBox(20, field, label);
box2.setFillWidth(false);
StackPane stackPane = new StackPane();
stackPane.setStyle("-fx-background-color: white; -fx-border-color: gray; -fx-border-width: .25px; -fx-padding: 20px;");
stackPane.getChildren().add(box2);
HBox box = new HBox(stackPane);
box.setStyle("-fx-padding: 100px;");
box.setAlignment(Pos.CENTER);
box.setFillHeight(false);
return box;
}
示例6: addHBox
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
/**
* Generates HBox for a header
* @return generated header.
*/
public HBox addHBox() {
HBox hbox = new HBox();
menuHamburger = new JFXHamburger();
hbox.setPadding(new Insets(15, 12, 15, -25));
hbox.setSpacing(10);
hbox
.setStyle(
"-fx-background-color: #336699;");
menuHamburger.setPrefSize(100, 20);
NAME_FIELD
.setStyle("" +
"-fx-font-size: 30; " +
"-fx-color-label-visible: false; " +
"-fx-text-fill: #FFFFFF");
nameLabel
.setStyle("" +
"-fx-font-size: 30; " +
"-fx-color-label-visible: false; " +
"-fx-text-fill: #FFFFFF");
hbox
.getChildren()
.addAll(menuHamburger, NAME_FIELD,nameLabel
);
return hbox;
}
示例7: initComponents
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
private void initComponents() {
content = new HBox();
collapsible = new HBox();
content.prefHeightProperty().bind(prefWidthProperty());
collapsible.prefWidthProperty().bind(prefWidthProperty());
getChildren().add(content);
content.setStyle("-fx-spacing: 10px;-fx-padding: 10px;-fx-border-color: silver;-fx-border-width: 1px;");
}
示例8: configureBox
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<AttClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock,lview);
bottomPane.setAlignment(Pos.CENTER);
//table pane
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Identication No.");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
typecol= new TableColumn<>("Type");
typecol.setMinWidth(130);
typecol.setCellValueFactory(new PropertyValueFactory<>("type"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例9: configureBox
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<OfficeClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock, lview);
bottomPane.setAlignment(Pos.CENTER);
nocol= new TableColumn<>("no");
nocol.setMinWidth(130);
nocol.setCellValueFactory(new PropertyValueFactory<>("no"));
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Admission Number");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(nocol,namecol, admcol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例10: start
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
try {
// Image setting = new Image(getClass().getResourceAsStream("setting.png"j));
Image logoimg = new Image(getClass().getResourceAsStream("logo.png"));
// Button settingbtn = new Button("",new ImageView(setting));
// settingLabel.setStyle("-fx-background-color:#1d1d1d");
JFXButton logobtn = new JFXButton("",new ImageView(logoimg));
Label title = new Label(" Energy Saving System");
title.setFont(new Font(30));
title.setPrefSize(650, 60);
title.setStyle("-fx-background-color:#1d1d1d; \n -fx-text-fill:white ;");
HBox hbox = new HBox();
hbox.setStyle("-fx-background-color:#1d1d1d");
hbox.setSpacing(10);
hbox.setPadding(new Insets(10,10,10,10));
hbox.getChildren().addAll(logobtn,title);
BorderPane root = new BorderPane();
root.setTop(hbox);
JFXTabPane pane = new JFXTabPane();
pane.setSide(Side.RIGHT);
Tab tab1 = new Tab();
Tab tab2 = new Tab();
Tab tab3 = new Tab();
tab3.setText("Settings");
tab2.setText("Tweaks");
tab2.setContent(new Tweaks().getPane());
tab1.setText("Statistics");
tab1.setContent(new ChartControls().getPane());
pane.getTabs().addAll(tab1,tab2,tab3);
root.setCenter(pane);
Scene scene = new Scene(root,910,550);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
示例11: constructContainer
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
@Override
public Parent constructContainer()
{
bp.setId("loginviewbg");
list = new ListView<String>();
items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
list.setItems(items);
AllFields = new VBox(50);
AllFields.setAlignment(Pos.CENTER);
AllFields.setMaxWidth(300);
AllFields.setPadding(new Insets(20));
tabPane = new TabPane();
tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
Tab tabDerive = new Tab();
tabDerive.setText("Derive");
HBox hbox = new HBox();
hbox.setPadding(new Insets(20, 0, 0, 0));
hbox.setStyle("-fx-font: 24 'System Regular'");
hbox.getChildren().add(new Label(tabDerive.getText()));
hbox.setAlignment(Pos.CENTER);
tabDerive.setContent(hbox);
Tab tabTeamwork = new Tab();
tabTeamwork.setText("Teamwork");
HBox hbox2 = new HBox();
hbox2.setPadding(new Insets(20, 0, 0, 0));
hbox2.setStyle("-fx-font: 24 'System Regular'");
hbox2.getChildren().add(new Label(tabTeamwork.getText()));
hbox2.setAlignment(Pos.CENTER);
tabTeamwork.setContent(hbox2);
tabPane.getTabs().addAll(tabDerive, tabTeamwork);
tabPane.getSelectionModel().getSelectedItem().setStyle("-fx-background-color:#a3a4a8");
tabPane.setOnMouseClicked(e -> {
for(Tab actTab:tabPane.getTabs())
{
actTab.setStyle("-fx-background-color:#f0f0f0");
}
tabPane.getSelectionModel().getSelectedItem().setStyle("-fx-background-color:#a3a4a8");
if(tabPane.getSelectionModel().getSelectedIndex()== 0)
{
btnContinue.setOnAction(ev -> getFXController().showView("deriveserverdoorview"));
} else
{
btnContinue.setOnAction(ev -> getFXController().showView("teamworkserverdoorview"));
}
});
SearchDMO = new HBox();
Bottom = new HBox();
txtDMO = new TextField();
txtDMO.setMinHeight(50);
txtDMO.setMinWidth(700);
txtDMO.setPromptText("Email-Adresse des Benutzers");
btnSearch = new AppButton("Suchen");
btnContinue = new AppButton("Weiter zum DMO");
back = new BackButton(getFXController(),"Zur�ck");
SearchDMO.getChildren().addAll(txtDMO,btnSearch);
Bottom.getChildren().addAll(back, btnContinue);
AllFields.getChildren().addAll(SearchDMO,list,Bottom);
bp.setTop(tabPane);
bp.setCenter(AllFields);
bp.setBottom(Bottom);
return bp;
}
示例12: createHorizontalBox
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public static HBox createHorizontalBox(double width, double height, String style)
{
HBox box = createHorizontalBox(width, height);
box.setStyle(style);
return box;
}
示例13: refresh
import javafx.scene.layout.HBox; //导入方法依赖的package包/类
public void refresh() {
reservationsWrapper.getChildren().clear();
int i = 0;
for(Reservation reservation : controller.getReservations()) {
HBox horizontalWrapper = new HBox();
horizontalWrapper.setSpacing(10);
horizontalWrapper.setAlignment(Pos.CENTER);
String filename = null;
switch (reservation.getSpot().getSpotType()) {
case HOUSE: filename = "cabin.png"; break;
case TRAILER: filename = "trailer.png"; break;
case RESTAURANT: filename = "cutlery.png"; break;
case PARKING: filename = "parking.png"; break;
case POOL: filename = "swimming-pool.png"; break;
case SPORT: filename = "kayak.png"; break;
case TENT: filename = "tent.png"; break;
}
Image bigImage = new Image(new File("res/items/x64/" + filename).toURI().toString());
ImageView locationImageView = new ImageView(bigImage);
HBox.setMargin(locationImageView, new Insets(0, 0, 0, 20));
horizontalWrapper.getChildren().add(locationImageView);
VBox verticalWrapper = new VBox();
horizontalWrapper.getChildren().add(verticalWrapper);
verticalWrapper.setAlignment(Pos.CENTER_LEFT);
horizontalWrapper.setOnMouseClicked(mouseEvent -> {
ReservationManagerDialog reservationManagerDialog = new ReservationManagerDialog(controller, reservation, new ImageView(bigImage));
reservationManagerDialog.showAndWait();
refresh();
});
verticalWrapper.setMinWidth(HomeView.TAB_CONTENT_W / 4);
verticalWrapper.setPadding(new Insets(20));
Client client = reservation.getClient();
Text clientNameText = new Text(client.getFirstname() + " " + client.getLastname());
clientNameText.setFont(new Font(20));
clientNameText.setFill(Color.WHITE);
verticalWrapper.getChildren().add(clientNameText);
Text spotText = new Text("Emplacement : " + reservation.getSpot().getName());
spotText.setFont(new Font(15));
spotText.setFill(Color.WHITE);
verticalWrapper.getChildren().add(spotText);
Text personCountText = new Text("Nombre de personnnes : " + reservation.getPersonCount());
personCountText.setFont(new Font(15));
personCountText.setFill(Color.WHITE);
verticalWrapper.getChildren().add(personCountText);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Text datesText = new Text("Dates début/fin : " + dateFormat.format(new Date(reservation.getStarttime().getTime())) + " / " + dateFormat.format(new Date(reservation.getEndtime().getTime())));
datesText.setFont(new Font(15));
datesText.setFill(Color.WHITE);
verticalWrapper.getChildren().add(datesText);
if (i++ % 2 == 1)
horizontalWrapper.setStyle("-fx-background-color: #336699;");
else
horizontalWrapper.setStyle("-fx-background-color: #0F355C;");
reservationsWrapper.getChildren().add(horizontalWrapper);
}
}
示例14: 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;
}
示例15: 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);
}