【发布时间】:2019-08-05 04:04:13
【问题描述】:
我的 jtextarea 有这个,我尝试了很多方法将其对齐在中心或右侧,但它总是在窗口之外
这是我现在得到的结果:
使用此代码:
Popup noticePopup = new Popup("Notice" , 1500, 900);
JPanel noticePanel = new JPanel();
noticePanel.setPreferredSize(new Dimension(1500,1000));
List<List> ListNote = controller.Medicament.consultationNotice(idMedoc);
String noticeThis =null;
for(int n=0;n<ListNote.size();n++) {
noticeThis = (String) ListNote.get(n).get(1);
}
JTextArea noticeArea = new JTextArea(noticeThis);
noticePopup.add(noticePanel);
noticePanel.add(noticeArea);
noticeArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
谢谢
【问题讨论】:
-
JTextPane对你有好处吗?因为JTextArea在文本对齐方面有一些障碍。看这里:stackoverflow.com/questions/24315757/… -
你为什么使用
Popup一个“重量级”AWT组件而其他的都是“轻量级”Swing组件? -
因为我需要在新页面上有这个文本