0

Modify the title bar of a panel in java code

asked 2013-04-26 08:59:05 +0800

JustinFrost gravatar image JustinFrost
145 1 6

Hi all,

I need to customise the title bar of a panel in java code. At the moment I have a panel as such:

Panel p = new Panel();
p.setTitle("Panel Title");
p.setCollapsible(true);
p.setClosable(false);
p.setMaximizable(false);

I need to add some tollbarButtons or a drop down menu on the titlebar without loosing the collapse button and title.

Do I use a caption to do this ? If so how do I add it to the titlebar there is no setCaption() methods on the panel and it only accepts panelChildren children.

Cheers for any assistance.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-04-26 09:19:59 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

updated 2013-04-26 09:25:41 +0800

    <panel title="test" collapsible="true" border="normal">
    <caption>
        <toolbar style="float: right;">
            <toolbarbutton label="one" />
            <toolbarbutton label="two" />
        </toolbar>
    </caption>
    <panelchildren>
        <label value="hello toolbar" />
    </panelchildren>
</panel>

That is the ZUL way to achieve this.

in Java:

    panel.appendChild(new Caption());
    Toolbar t = new Toolbar();
    t.setStyle("float: right;");
    root.getCaption().appendChild(t);
    Toolbarbutton b1 = new Toolbarbutton("one");
    Toolbarbutton b2 = new Toolbarbutton("two");
    t.appendChild(b1);
    t.appendChild(b2);

Giovanni

link publish delete flag offensive edit

Comments

Thanks for the response, unfortunately does not work for me.

The panel.appendChild(new Caption()) throws:

org.zkoss.zk.ui.UiException: Unsupported child for Panel: [caption ]

JustinFrost ( 2013-04-29 07:38:49 +0800 )edit
0

answered 2013-04-29 07:59:16 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6
http://www.hybris.com/

I tested this code and it works fine... what version of ZK are you using? I checked wuth 6.5.2 EE and 6.5.1 CE and it works...

    <zk>
    <panel id="root" title="test" collapsible="true" border="normal">
        <panelchildren>
            <label value="hello toolbar" />
        </panelchildren>
    </panel>
    <zscript><![CDATA[
        root.appendChild(new Caption());
        Toolbar t = new Toolbar();
        t.setStyle("float: right;");
        root.getCaption().appendChild(t);
        Toolbarbutton b1 = new Toolbarbutton("one");
        Toolbarbutton b2 = new Toolbarbutton("two");
        t.appendChild(b1);
        t.appendChild(b2);
    ]]></zscript>
</zk>
link publish delete flag offensive edit

Comments

Sorry gganassin, my mistake I use using the wrong Caption class...Thanks for your help.

JustinFrost ( 2013-04-29 08:07:27 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-04-26 08:59:05 +0800

Seen: 44 times

Last updated: Apr 29 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More