java getchildren用法_Java HBox.getChildren方法代码示例

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 buttons = hbox.getChildren();

Set 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;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值