나는 Dialog 및 TextArea
을 가지고 있습니다. TextArea
구성 요소의 맞춤은 Component.CENTER
입니다.TextArea 텍스트를 가운데에 배치하는 방법은 무엇입니까?
public class Alert extends Dialog {
private TextArea chp;
private Command[] comms;
public Alert(String text, Command[] comms)
{
super();
this.comms = comms;
setAutoDispose(true);
for (int c=0; c<comms.length; c++)
addCommand(comms[c]);
chp = new TextArea(text);
chp.setAlignment(Component.CENTER);
chp.setEditable(false);
chp.getSelectedStyle().setBorder(null);
chp.getUnselectedStyle().setBorder(null);
chp.getSelectedStyle().setBgColor(this.getStyle().getBgColor());
chp.getUnselectedStyle().setBgColor(this.getStyle().getBgColor());
chp.setRowsGap(3);
}
public Command affiche()
{
return show(null, chp, comms);
}
}
내 문제는 다른 양식에서 affiche()
메서드를 호출 할 때 텍스트가 TextArea
의 상단에 표시됩니다이다 : 나는 대화 상자를 표시 affiche()
라는 방법을 만들었습니다.
TextArea
의 가운데에 텍스트를 표시하는 방법은 무엇입니까? 나는 너비가 중심이고 높이가 중심 인 것을 "센터링"하는 것을 의미합니다. 이미 수평 정렬을 코드 chp.setAlignment(Component.CENTER);
을 중심으로 설정 했으므로 수직 정렬을 설정하는 방법을 알고 싶습니다.
이 코드를 구현하는 방법과 예제를 제공하십시오. –
아래 코드를 시도했습니다. 그것은 프로젝트에서 일하고 있습니다. textArea.getStyle(). setAlignment (CENTER); // 여기 textArea는 TextArea의 인스턴스입니다. – Thirumalvalavan