面向垂直的,从右到左的JList,用于中文文本

时间:2016-12-19 01:44:53

标签: java jlist

这可能吗?

我希望我能告诉你我的代码,但我不知道从哪里开始。我还没有在谷歌上找到一个例子。

如果有可能,有人可以请我参考样品吗?

LstGlossary.setModel(
new javax.swing.AbstractListModel() { String[] strings = { "你好", "哈囉" }; 
public int getSize() { return strings.length; } 
public Object getElementAt(int i) { return strings[i]; } 
}); 
LstGlossary.setComponentOrientation(ComponentOrientation.RIG‌​HT_TO_LEFT);

以下是这两个字符串在Microsoft Word中从右到左显示垂直文本方向的内容:

Vertical, Right to Left Chinese Text

1 个答案:

答案 0 :(得分:2)

使用setComponentOrientation方法:

jlist.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

来自Javadoc:

  

设置用于订购的语言敏感方向   此组件中的元素或文本。语言敏感   LayoutManager和Component子类将使用此属性   确定如何布局和绘制组件。