Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to select particular rectangle box from canvas?( I have develop simple example base on SWT. Now I want to select a particular rectangle using selection or any other event? how to give selection event to particular rectangle?)
icon8.gif  how to select particular rectangle box from canvas? [message #1748237] Mon, 21 November 2016 13:19
Sumit Fataniya is currently offline Sumit FataniyaFriend
Messages: 12
Registered: July 2016
Junior Member
Qes: I have develop simple example base on SWT. Now I want to select a particular rectangle using selection or any other event? how to give selection event to particular rectangle?

Code:

public class DrawRoundRectangle {
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText("Canvas Example");

shell.setLayout(new GridLayout(1, true));

final Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
canvas.setLayout(null);

canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
// Point p = canvas.getSize();
for (int i = 0; i < 10; i++) {
// e.gc.drawRoundRectangle(10, 10, e.width, e.height, 0, 0);

e.gc.drawRoundRectangle((6 * i), (6 * i), e.width
- (14 * i), e.height - (14 * i), 0, 0);
e.gc.drawText("", (6 * i), (6 * i));
}

}
});

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
  • Attachment: ablokdia.JPG
    (Size: 58.51KB, Downloaded 137 times)
Previous Topic:Wrap Text on SWT Table Cell
Next Topic:how to select particular rectangle box from canvas?
Goto Forum:
  


Current Time: Tue Apr 23 08:27:00 GMT 2024

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

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

Back to the top