java - SWT Horizontal line after Text fully expanded -
i'm trying display history in textfield in swt.
the history generates new shell has 2 composites. first displays header part contains label "history" , horizontal line underneath. second footer part display actual data. works, horizontal line not expanded (i.e.: "filled") throughout available horizontal space (i.e.: until composite "end").
public void mousedown(final mouseevent e) { findsegmenttext.settext(""); if(0 == lastsegmentids.size()) return; if(disabletooltipsbutton.getselection()) return; // context not desired if(null != popupshell) popupshell.dispose(); popupshell = new shell(display.getdefault(), swt.border | swt.on_top | swt.modeless); //popupshell.setlayoutdata(new griddata(griddata.fill_horizontal)); popupshell.setlayout(createnomarginlayout(1, false)); /* header */ compositesearchsegments1 = new composite(popupshell, swt.none); compositesearchsegments1.setlayoutdata(new griddata(griddata.fill_horizontal)); compositesearchsegments1.setlayout(createnomarginlayout(1, false)); /* footer */ compositesearchsegments2 = new composite(popupshell, swt.none); compositesearchsegments2.setlayoutdata(new griddata(griddata.fill, griddata.fill, true, true)); compositesearchsegments2.setlayout(createnomarginlayout(2, false)); label history = new label(compositesearchsegments1, swt.none); history.settext("history"); label line1 = new label(compositesearchsegments1, swt.separator | swt.shadow_out | swt.horizontal); for(int = lastsegmentids.size()-1 ; i>=0;i--) { // iterate backwards, higher indexes have newer selected links final string lastsegmentid = lastsegmentids.get(i); l.settext(lastsegmentid); button b = new button(compositesearchsegments2, swt.none); b.setvisible(true); b.settext(">>"); b.setsize(10,10); b.addselectionlistener(new selectionadapter() { @override public void widgetselected(selectionevent e) { findsegmenttext.settext(lastsegmentid); searchanddisplaylink(long.decode(findsegmenttext.gettext())); } }); } point point = optionscomposite.todisplay(e.x + optionscomposite.getbounds().x +findsegmenttext.getlocation().x, e.y + optionscomposite.getbounds().y+findsegmenttext.getlocation().y ); popupshell.setlocation(point.x-125, point.y-10); popupshell.pack(); popupshell.open(); findsegmenttext.setfocus(); }
which produces result:
i expand line fill available horizontal space. should do? thank you.
since using gridlayout
, adding griddata
separator label
trick:
public static void main(string[] args) { display display = new display(); shell shell = new shell(display); shell.settext("stackoverflow"); shell.setlayout(new gridlayout(1, false)); label first = new label(shell, swt.none); first.settext("short"); label separator = new label(shell, swt.separator | swt.shadow_out | swt.horizontal); separator.setlayoutdata(new griddata(swt.fill, swt.center, true, false)); label second = new label(shell, swt.none); second.settext("looooooooooooooooooooooooooooooooooooong"); shell.pack(); shell.open(); while (!shell.isdisposed()) { if (!display.readanddispatch()) display.sleep(); } display.dispose(); }
looks this:
Comments
Post a Comment