开发者

Adding a button to the title bar using Substance LAF

I'm trying to add a button to my title bar. It doesn't seem to show and some reason hides the title words.

In my JFrame I do:

CustomTitlePane.editTitleBar(this);

And my title class:

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)开发者_StackOverflow中文版;
        title.add(titleButton,2);
    }
}


Found the answer. The title bar has no layout and therefore you need to add bounds to what ever you add like so:

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

Now you will get a nice button after the icon and before the title :)

The other option is to add a layout manager to the title bar.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜