RIGHT_TO_LEFT 的 JTableHeader 组件方向错误 + JScrollPane 中的 AUTO_RESIZE_OFF

发布于 2024-09-12 00:29:57 字数 1515 浏览 1 评论 0原文

在 Java 6u16、WinXP SP3 上使用 Swing
大家好。我需要一些帮助,请处理以下案例。 基本上我在 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);
    }
}

请帮我解决这个问题,因为我没有通过谷歌找到任何东西,也无法自己解决这个问题。

Using Swing on Java 6u16, WinXP SP3
Hello to all. I need some help, please, with the following case.
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文