【问题标题】:How to use the SwingX JXTitledSeparator?如何使用 SwingX JXTitledSeparator?
【发布时间】:2013-04-23 07:21:26
【问题描述】:

我正在尝试使用 SwingX 中的 JXTitledSeparator 创建带有标题的分隔符,如下所示:

这是我目前使用的代码:

JXTitledSeparator xTitledSeparator1 = new JXTitledSeparator();
xTitledSeparator1.setTitle( "Separator Title" );
xTitledSeparator1.setHorizontalAlignment(0);

但我真正想要的是将分隔标题“Separator Title”向左移动一点,所以它可以看起来像这样:

有没有办法做到这一点?

【问题讨论】:

    标签: java separator swingx


    【解决方案1】:

    试试

    xTitledSeparator1.setHorizontalAlignment(SwingConstants.LEFT);
    

    SwingConstants.LEADING。您使用的0 代表SwingConstants.CENTER

    如果这不起作用,请尝试setHorizontalTextPosition(SwingConstants.LEFT)

    【讨论】:

    • 谢谢,但这会将标题移到最左侧,不会产生上图的效果。我希望将文本移动一点。
    • @Brad 在这种情况下,除了获取JXTitledSeparator 的来源并更改方法layoutSeparator() 之外,我没有看到其他解决方案
    • 非常感谢。我选择的解决方案是在 JXTitledSeparator 左侧使用另一个 JSeparator,我为其使用 SwingConstants.LEFT 属性,以在上面的屏幕截图中给出结果。
    猜你喜欢
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    相关资源
    最近更新 更多