Example usage for org.eclipse.swt.widgets Label getParent

List of usage examples for org.eclipse.swt.widgets Label getParent

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Label getParent.

Prototype

public Composite getParent() 

Source Link

Document

Returns the receiver's parent, which must be a Composite or null when the receiver is a shell that was created with null or a display for a parent.

Usage

From source file:ShowInputDialog.java

private void createContents(final Shell parent) {
    parent.setLayout(new FillLayout(SWT.VERTICAL));

    final Label label = new Label(parent, SWT.NONE);

    Button button = new Button(parent, SWT.PUSH);
    button.setText("Push Me");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create and display the InputDialog
            InputDialog dlg = new InputDialog(parent);
            String input = dlg.open();
            if (input != null) {
                // User clicked OK; set the text into the label
                label.setText(input);//w ww.  j a v  a  2  s  . co m
                label.getParent().pack();
            }
        }
    });
}