패널을 만들 때 GridBagLayout
을 사용합니다.GridBagLayout aligment issue
패널의 오른쪽 구석에있는 삭제 아이콘을 사용하고 싶습니다. 그러나 JTextArea
이 패널에 추가되지 않으면 삭제 아이콘이 왼쪽으로 이동합니다.
누군가 제대로 할 수있는 방법을 말해 줄 수 있습니까?
는에 weightx
및 anchor
의 조합을 사용하여 패널
private void buildTopJPane() {
try {
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.NONE;
this.add(setAttonIconCreator(), c);
c.gridx = 5;
c.gridy = 0;
c.gridwidth = 4;
this.add(setDeleteIcon(), c);
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 4;
this.add(setPageDateLabel(), c);
if (thisComment.content != null) {
if (thisComment.content.length() > 0)
c.gridx = 0;
c.gridy = 2;
c.gridwidth = 4;
this.add(setContent(), c);
}
} catch (Exception err) {
Utility.DisplayErrorMsg(pageErrorPrefix + err.getMessage().toString());
}
}
제안 해 주셔서 감사합니다. 삭제 아이콘에 GridBagConstraints.NORTHEAST를 설정하고 오른쪽 상단 구석에 배치합니다. – user819774