0
ツールバー内のイメージをツールバー内の右に少し移動する方法を知っている人がいるかどうかは不思議でした。JavaFxのツールバーでイメージを移動する方法
これは私が持っているもの現在:https://i.stack.imgur.com/vZnzX.png
私はツールバーでの複数の中央ので、それは右にのみカップルの画素移動することにしたいです。
Image robotIcon = new Image(getClass().getResourceAsStream("robot-16.png"));
ImageView robotView = new ImageView(robotIcon);
robotView.setFitHeight(50);
robotView.setFitWidth(50);
Label robotImage = new Label("");
robotImage.setGraphic(robotView);
ToolBar toolBar2 = new ToolBar();
toolBar2.setOrientation(Orientation.VERTICAL);
toolBar2.getItems().addAll(
controlLabel,
new Separator(),
gameLabel,
rdoStart,
rdoStop,
new Separator(),
animationLabel,
rdoRestart,
new Separator(),
simulationLabel,
btnRobot,
delRobot,
new Separator(),
robotLabel,
difSizeRobot,
sameSizeRobot,
new Separator(),
robotSpeedLabel,
difSpeedRobot,
sameSpeedRobot,
new Separator(),
objectSpawnLabel,
solidObject,
solidCircle,
robotImage
);
あなたは単にfi単純に 'robotImage.setPadding(new Insets(0、0、0、5))'(例えば)を行うことができます。実際にそれを中心にしたい場合は、ラベルの最大幅を 'Double.MAX_VALUE'に設定し、' alignment'を 'CENTER'に設定してみてください(ただし、ツールバーのレイアウト管理方法は完全にはわかりません)。 –
@ James_DオハイはsetPaddingのことについては考えていませんでしたが、それが問題を解決しました!私は今ツールバーでそれを移動することができます、ありがとう! –