Composite parent = new Composite(shell, SWT.NONE); Rectangle clientArea = parent.getClientArea(); Label label = new Label(parent, SWT.NONE); label.setBounds(clientArea.x + 10, clientArea.y + 10, 100, 20);
Composite parent = new Composite(shell, SWT.NONE); Rectangle clientArea = parent.getClientArea(); Canvas canvas = new Canvas(parent, SWT.NONE); canvas.setBounds(clientArea);Here, we create a new Composite and retrieve its client area. We then create a new Canvas widget and set its bounds to the entire client area of the parent Composite. These examples demonstrate how the getClientArea method can be used to determine the available area for child widgets within a Composite container. The package library for org.eclipse.swt.widgets.Composite is part of the Eclipse Foundation's Standard Widget Toolkit (SWT) for creating graphical user interfaces in Java.