Jump to content

delete rectangle in SWT

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
eman ahmed

eman ahmed

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Hi,all
I Want to Kow How can I delete a rectangle in SWT?

#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
What do you mean "delete" a Rectangle in SWT? If you drop all references to a Rectangle object, the garbage collector will clean it up on it's own just like every other Java object, so the best way would be to simply remove the reference to the rectangle.
import org.eclipse.swt.graphics.Rectangle;

public class Main
{
    public static void main(String[] args)
    {
        Rectangle r = new Rectangle(0, 0, 100, 100);
        r = null; // GC will soon collect the now dereferenced Rectangle.
    }
}

Wow I changed my sig!

#3
eman ahmed

eman ahmed

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
if I declacre new gc an write gc.drawrecangle(rectangle) ,the rectangle will drawn. after that if I write rectangle=null .I obsrved that the rectangle still in shell and doesn't deleted from the shell.
I want t o ask another question how can I make event when mouse scroll move

Edited by eman ahmed, 19 October 2010 - 01:18 PM.


#4
Metalhead

Metalhead

    Newbie

  • Members
  • PipPip
  • 27 posts
Just use an addMouseWheeelListener to the component you want to listen to;
How to Write a Mouse-Wheel Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)

#5
Metalhead

Metalhead

    Newbie

  • Members
  • PipPip
  • 27 posts
*double post*

Edited by Metalhead, 19 October 2010 - 11:11 AM.
Deleted duplicate post