Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to drag clabel,button,table widgesfrom left,right,top and bottom(resize a composite)
How to drag clabel,button,table widgesfrom left,right,top and bottom [message #1821854] Fri, 21 February 2020 07:16
zhang lei is currently offline zhang leiFriend
Messages: 22
Registered: July 2012
Junior Member
I want to make a report tools 。
In the programe ,Through the mouse,I can draw a comosite,label,button,table and so present ,I add a mouse listener to the canavas,I can make a widges.but I do not konw how to resize the widges.

I find a way . use the Tracker,but I find it not work verry well! it work like this
I want get a good effect .when the mouse click the composite widges,it's four sides is lines and drag one line or corner, I can resize the composite.
can you help me ?thank you very much !

In is the programe,it use the not well.
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;

public class DragComposite {
	public static void main(String[] args) {

	    Display display = new Display();
	    final Shell shell = new Shell(display);;

	    final Composite b = new Composite(shell, SWT.NONE);
	    b.setBounds(20, 20, 80, 80);
	    b.addListener(SWT.MouseDown, new Listener() {

	      public void handleEvent(Event e) {

	        Tracker tracker = new Tracker(b.getParent(), SWT.RESIZE |SWT.LEFT|SWT.RIGHT|SWT.BOTTOM|SWT.TOP);
	        Rectangle rect = b.getBounds();
	        tracker.setRectangles(new Rectangle[] { rect });
	        //tracker.setCursor(new Cursor(shell.getDisplay(),SWT.CURSOR_HAND));
	        if ( {
	          Rectangle after = tracker.getRectangles()[0];
	    while (!shell.isDisposed()) {
	      if (!display.readAndDispatch())

  • Attachment: 1.jpg
    (Size: 45.99KB, Downloaded 163 times)
  • Attachment: 2.jpg
    (Size: 163.03KB, Downloaded 146 times)
Previous Topic:Drag and Drop from SWT to embbedded AWT frame (SWT_AWT) is broken on Linux GTK 3.22
Next Topic:Standalone SWT with Central Maven repo
Goto Forum:

Current Time: Tue Apr 13 05:50:53 GMT 2021

Powered by FUDForum. Page generated in 0.02156 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top