java 图形界面的AWT编程 如何使得List控件里每一项上的文字都右对齐

来源:百度知道 编辑:UC知道 时间:2024/06/07 00:42:15
默认的是左对齐,怎么改成右对齐

setComponentOrientation

public void setComponentOrientation(ComponentOrientation o)

设置语言敏感的方向,用于排序此组件内的元素或文本。语言敏感的 LayoutManager 和 Component 子类使用此属性来确定如何布局并绘制组件。
在构造时,组件的方向设置为 ComponentOrientation.UNKNOWN,表示尚未显式地指定它。UNKNOWN 方向的行为与 ComponentOrientation.LEFT_TO_RIGHT 相同。

要设置单个组件的方向,请使用此方法。要设置整个组件层次结构的方向,请使用 applyComponentOrientation。

另请参见:
ComponentOrientation

//UNKNOWN 方向的行为与 ComponentOrientation.LEFT_TO_RIGHT 相同。
//默认方向
//自己改一下需要的对其方向RIGHT_TO_LEFT