/** * Makes the panel collapsible. * * <p>When <code>on</code> is <code>true</code>, a collapse/expand icon is added to the title bar. * This also calls setTitleBar(true) to enable the title bar. * * <p>The default value is <code>false</code>. * * <p> * * @see WPanel#setTitleBar(boolean enable) * @see WPanel#setCollapsed(boolean on) * @see WPanel#isCollapsed() */ public void setCollapsible(boolean on) { if (on && !(this.collapseIcon_ != null)) { String resources = WApplication.getResourcesUrl(); this.setTitleBar(true); this.collapseIcon_ = new WIconPair(resources + "collapse.gif", resources + "expand.gif"); this.collapseIcon_.setInline(false); this.collapseIcon_.setFloatSide(Side.Left); this.getTitleBarWidget().insertWidget(0, this.collapseIcon_); this.collapseIcon_ .icon1Clicked() .addListener( this, new Signal1.Listener<WMouseEvent>() { public void trigger(WMouseEvent e1) { WPanel.this.doCollapse(); } }); this.collapseIcon_ .icon1Clicked() .addListener( this, new Signal1.Listener<WMouseEvent>() { public void trigger(WMouseEvent e1) { WPanel.this.onCollapse(); } }); this.collapseIcon_ .icon2Clicked() .addListener( this, new Signal1.Listener<WMouseEvent>() { public void trigger(WMouseEvent e1) { WPanel.this.doExpand(); } }); this.collapseIcon_ .icon2Clicked() .addListener( this, new Signal1.Listener<WMouseEvent>() { public void trigger(WMouseEvent e1) { WPanel.this.onExpand(); } }); this.collapseIcon_.setState(0); } else { if (!on && this.collapseIcon_ != null) { if (this.collapseIcon_ != null) this.collapseIcon_.remove(); this.collapseIcon_ = null; } } }