【问题标题】:Adding a button to the title bar using Substance LAF使用 Substance LAF 向标题栏添加按钮
【发布时间】:2010-11-27 23:22:52
【问题描述】:

我正在尝试向我的标题栏添加一个按钮。好像没有 显示并且出于某种原因隐藏了标题词。

在我的 JFrame 中我这样做:

CustomTitlePane.editTitleBar(this);

还有我的职称类:

public class CustomTitlePane extends SubstanceTitlePane {

    private static final long serialVersionUID = 1L;

    public CustomTitlePane(JRootPane root, SubstanceRootPaneUI ui) {
        super(root, ui);
}
    public static void editTitleBar(JFrame frame){
        JComponent title = SubstanceLookAndFeel.getTitlePaneComponent(frame);
        JButton titleButton = new JButton("test");

titleButton.putClientProperty("substancelaf.internal.titlePane.extraComponentKind", ExtraComponentKind.TRAILING);
        title.add(titleButton,2);
    }
}

【问题讨论】:

    标签: java swing substance


    【解决方案1】:

    找到答案。标题栏没有布局,因此您需要为添加的内容添加边界,如下所示:

    titleButton.setBounds(20, 0, 40, 20);
    

    现在您将在图标之后和标题之前获得一个不错的按钮:)

    另一个选项是向标题栏添加布局管理器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多