Rectangle « Drag Drop « Java Swing Q&A





1. Draw rectangle by dragging mouse    coderanch.com

Here..I am posting my code...I have modified it. It is now displaying rectangle but during dragging mouse it is showing all mouse moves. public void makeRectangle(int x1, int y1, int x2, int y2,Display display) { // TODO Auto-generated method stub GC gc = new GC(display); gc.drawRectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x1 - x2), Math.abs(y1 - y2)); gc.dispose(); } public void run(IAction action) ...