java - How to get the scrollbars to work in a ScrolledComposite when using GridLayout? -
i trying have scrolled composite fixed size content , label below scrolled composite display status information of scrollable content. want controls resize parent, have used gridlayout on parent. facing issue scroll bars of scrolled composite , positioning of label control. i.e, scrolling doesn't work unless set scrolledcomposite's grid data attribute as
grabexcessverticalspace = true
if allow scrolledcomposite grab excess vertical space, label not appear below scrolledcomposite due space between them.
public class snippet5 { public static void main(string[] args) { display display = new display(); shell shell = new shell(display); shell.setlayout(new gridlayout(1, true)); // button 400 x 400. scrollbars appear if window // resized small show part of button scrolledcomposite c1 = new scrolledcomposite(shell, swt.border | swt.h_scroll | swt.v_scroll); button b1 = new button(c1, swt.push); b1.settext("fixed size button"); b1.setsize(400, 400); c1.setalwaysshowscrollbars(true); c1.setlayoutdata(new griddata(swt.left, swt.top, true, true)); c1.setcontent(b1); label l = new label(shell, swt.border); l.settext("button clicked"); griddata layoutdata = new griddata(swt.left, swt.top, true, false); layoutdata.heighthint = 30; layoutdata.widthhint = 400; l.setlayoutdata(layoutdata); shell.setsize(600, 300); shell.open(); while (!shell.isdisposed()) { if (!display.readanddispatch()) display.sleep(); } display.dispose(); } }
any in having label appear below scrolled composite (trim space) , have scrolling work appreciated.
edit:
expected behavior:
- extra vertical space grabbed label.
- the scrolledcomposite should enable vertical scrolling when content cannot viewed when shell re-sized.
you need set layout data of scrolledcomposite
fill
so:
new griddata( swt.fill, swt.fill, true, true );
this way, scrolledcomposite take available space of grid cell.
Comments
Post a Comment