GridPane
에는 1 자루의 레이블이 있습니다.JavaFx GridPane - 요소 가운데 놓는 방법
int charSpacing = 1;
int charsInWidth = 28;
int charsInHeight = 16;
double charWidth = 15;
double charHeight = 20;
GridPane gp = new GridPane();
gp.setAlignment(Pos.CENTER);
Label[] tmp = new Label[charsInHeight*charsInWidth];
String text = "W";
int currArrPos = 0;
for(int y = 0; y < charsInHeight; y++) {
HBox hbox = new HBox(charSpacing);
for(int x = 0; x < charsInWidth; x++) {
tmp[currArrPos] = new Label(text);
tmp[currArrPos].setTextFill(Paint.valueOf("white"));
tmp[currArrPos].setMinHeight(charHeight);
tmp[currArrPos].setMinWidth(charWidth);
tmp[currArrPos].setMaxHeight(charHeight);
tmp[currArrPos].setMaxWidth(charWidth);
tmp[currArrPos].setStyle("-fx-border-color: white;");
hbox.getChildren().add(tmp[currArrPos++]);
if(x%2 == 0){
text = "I";
} else{
text = "W";
}
}
gp.add(hbox, 1, y);
}
guiDisplay.getChildren().add(gp);
가 어떻게 문자를 중심으로 수
다음image http://s1.directupload.net/images/121010/xu8o79sr.jpg
코드입니다 : 여기
은 이미지입니다?나는 이것을 HBox
에 넣고 간격을 둡니다. 나는 CENTER
이라는 레이블의 textAlignment
을 만들려고했지만 물론 작동하지 않습니다.
gp.setAlignment(Pos.CENTER);
아이디어를 사람을 했습니까? 감사!