java - How to fill a ScrolledComposite? -


i have class extending scrolledcomposite, within class have created composite intended fill parent scrolledcomposite. whenever add labels inner composite wraps upper right corner only. want inner composite fill outer scrolledcomposite. there way this?

    public class container extends scrolledcomposite {      final composite comp;     label namelabel, sizelabel, datelabel;     arraylist<label> entrysize, date;     arraylist<simpleentry> entry;     color white;     font font;      public container(composite parent, int style) {         super(parent, style);         white = new color(getdisplay(), 255, 255, 255);         font = new font(getdisplay(), "arial", 16, swt.bold);         setbackground(white);         setlayout(new gridlayout(1, false));          comp = new composite(this, swt.border);         griddata compdata = new griddata(swt.fill, swt.fill, true, true);         comp.setlayoutdata(compdata);         setcontent(comp);         comp.setbackground(white);         comp.setlayout(new gridlayout(3, false));          namelabel = new label(comp, swt.bold);         sizelabel = new label(comp, swt.bold);         datelabel = new label(comp, swt.bold);          griddata d1 = new griddata(swt.center, swt.center, true, false);         namelabel.setlayoutdata(d1);          griddata d2 = new griddata(swt.center, swt.center, true, false);         sizelabel.setlayoutdata(d2);          griddata d3 = new griddata(swt.center, swt.center, true, false);         datelabel.setlayoutdata(d3);          namelabel.setbackground(white);         sizelabel.setbackground(white);         datelabel.setbackground(white);          namelabel.settext("name");         sizelabel.settext("size");         datelabel.settext("last modified");          namelabel.setfont(font);         sizelabel.setfont(font);         datelabel.setfont(font);          comp.setsize(comp.computesize(swt.default, swt.default));         comp.layout();          adddisposelistener(new disposelistener() {             @override             public void widgetdisposed(disposeevent e) {                 container.this.widgetdisposed(e);             }         });     } } 

just add these lines @ end of constructor:

this.setminsize(comp.computesize(swt.default, swt.default)); this.setexpandhorizontal(true); this.setexpandvertical(true); 

notes:

  • remember dispose() resources create (color, font, ...)
  • consider using system resources (no need dispose) using display.getsystemcolor(swt.color_white) , display.getsystemfont().

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -