开发者

Wrong JTableHeader component orientation with RIGHT_TO_LEFT + AUTO_RESIZE_OFF in JScrollPane

Using Swing on Java 6u16, WinXP SP3

Hello to all. I need some help, please, with the following cas开发者_StackOverflow社区e. Basically I use a JTable inside a JScrollPane, that on the scrollPane I apply component orientation of right-to-left. The final result that I get is such that the table is indeed is attached to the right, but the header is placed to the left, when the scroll pane is bigger than the table width. This is happens only with custom table headers and AUTO_RESIZE_OFF on table columns (to get horizontal scrolling).

Second (related) problem is with dragging the vertical grid lines to resize the columns - the header line moves to the left, when the table column's line moves to the right. I have 2 test cases. The first uses the code from http://www.swebb99.f2s.com/GroupableHeader/. This is open source implementation of the table header that is used to group some sub-column headers. Please add to main() in GroupableColumnExample.java:

frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

Second test case uses JIDE (www.jidesoft.com) implementation of nested table header for the same purpose and with the same results.

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);
    }
}

Please help me to resolve this, as I did not find anything via Google and cannot resolve the issue myself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜