0
툴바에서 이미지를 툴바 내에서 오른쪽으로 약간 이동시키는 방법을 아는 사람이 있는지 궁금합니다.JavaFx의 ToolBar에서 이미지를 옮기는 방법
이 내가 무엇을 현재 : 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로 이동하려는 경우 xed 픽셀 수를 사용하면 'robotImage.setPadding (new Insets (0, 0, 0, 5))'(예를 들어)을 간단히 수행 할 수 있습니다. 실제로 중심에 배치하고 싶다면 라벨의 최대 폭을'Double.MAX_VALUE'로 설정하고'alignment '를'CENTER'로 설정해보십시오 (툴바가 레이아웃을 관리하는 방법을 완전히 확신 할 수는 없지만). –
@ James_D 오하이오는 setPadding에 대해 생각하지 않았지만 문제가 해결되었습니다! 도구 모음에서 이동할 수 있습니다. 감사합니다. –