This week's book giveaway is in the Java in General forum. We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line! See this thread for details.
Hi all,
I want to draw a rectangle by dragging mouse using SWT. I am getting co-ordinates of starting point and endpoint but rectangle is not drawn.
Please help me about this.
Thanks in advance...
How are you calling the makeRectangle method? Are you calling it from paintComponent? What's GC? Is it some sort of Graphics object? How did you write your PaintListener class?
Last time I had that exercise I created a Shape interfaceand a Rectangle class which implemented that interface and I put the object into a List and drew all the elements in that List in the paintComponent method. Of course, there is a Graphics object implicitly passed to the paintComponent method, ready for you to use. What about calling repaint() on the display from your mouse listener methods?
Please note the code button makes your posts look much better. I have edited your post, since you are new, to show it to full effect.
Campbell Ritchie wrote:How are you calling the makeRectangle method? Are you calling it from paintComponent? What's GC? Is it some sort of Graphics object? How did you write your PaintListener class?
...
I'm not sure if these concerns are relevant in GUI programs that use the SWT library, but I must plead ignorance since I don't use this library.