在Java 6u16上使用Swing,WinXP SP3
大家好。我需要一些帮助,请注意以下情况。
基本上我在JScrollPane中使用JTable,在scrollPane上我应用从右到左的组件方向。我得到的最终结果是表格确实附在右边,但当滚动窗格大于表格宽度时,标题放在左侧。这只发生在表列上的自定义表头和AUTO_RESIZE_OFF(以获得水平滚动)。
第二个(相关)问题是拖动垂直网格线以调整列的大小 - 标题行移动到当表列的行向右移动时,向左移动。 我有2个测试用例。第一个使用http://www.swebb99.f2s.com/GroupableHeader/中的代码。这是表头的开源实现,用于对一些子列标题进行分组。 请添加到GroupableColumnExample.java中的main():
frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
第二个测试用例使用嵌套表头的JIDE(www.jidesoft.com)实现,用于相同的目的并具有相同的结果。
import java.awt.ComponentOrientation;
import javax.swing.*;
import com.jidesoft.grid.JideTable;
public class TestCase {
public static void main(String[] args) {
JFrame frame = new JFrame("Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JideTable table = new JideTable(
new Object[][]{{"1", "2"}}, new String[]{"3", "4"});
//this line adds the custom header and the problem begins
table.setNestedTableHeader(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
frame.add(new JScrollPane(table));
//make frame bigger than needed to display the table
frame.setSize(200, 200);
frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
frame.setVisible(true);
}
}
请帮我解决此问题,因为我没有通过Google找到任何内容,也无法自行解决此问题。