Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » a SWT control refuses to "grab excess vertical space"
a SWT control refuses to "grab excess vertical space" [message #688182] Fri, 24 June 2011 05:30
Zhao Han is currently offline Zhao HanFriend
Messages: 1
Registered: June 2011
Junior Member
The case is that the TopTaskGroup(left one) can "grab excess vertical space" while resizing window, but the NewTaskGroup(the right one), after adding a TooBar on it(see the createAddBtnOnGroup method), it doesn't grow as you resize the window. Why is that?

(I have a shell instance with 2-column GridLayout)

Before resizing:
i.stack.imgur.com/hnBlp.png

after resizing
i.stack.imgur.com/obpQn.png

Code is here:

private void createTaskWidgets() {
    createTopTaskGroup();
    createNewTaskGroup();
}

private void createTopTaskGroup() {
    Group topTasksGroup = new Group(shell, SWT.SHADOW_NONE);
    topTasksGroup.setText(TaskConsts.TOP_TASK_LIST);

    topTasksTable = new TaskTable(topTasksGroup, TaskTable.SORT_BY_VOTES, iteration, this);
    topTasksTable.setLayoutData(getTableGridData() );

    topTasksGroup.setLayout(new GridLayout() );
    topTasksGroup.setLayoutData(getTableGridData() );
    topTasksGroup.pack();
}

private void createNewTaskGroup() {
    Group newTasksGroup = new Group(shell, SWT.SHADOW_NONE);
    newTasksGroup.setText(TaskConsts.NEW_TASK_LIST);

    newTasksTable = new TaskTable(newTasksGroup, TaskTable.SORT_BY_CREATION_TIME, iteration, this);
    topTasksTable.setLayoutData(getTableGridData() );

    ToolBar actionToolBar = createAddBtnOnGroup(newTasksGroup);

    newTasksGroup.setLayout(new GridLayout() );
    newTasksGroup.setLayoutData(getTableGridData() );
    newTasksGroup.layout();
    newTasksGroup.pack();

    // set actionToolBar's location to newTasksGroup's right-top position
    actionToolBar.setLocation(
            newTasksGroup.getLocation().x + newTasksGroup.getSize().x
                    - actionToolBar.getSize().x - 5,
            newTasksGroup.getLocation().y - 2);
}

private GridData getTableGridData() {
    GridData gridData = new GridData(0, SWT.FILL, false, true);
    return gridData;
}

private ToolBar createAddBtnOnGroup(Group newTasksGroup) {
    ToolBar actionToolBar = new ToolBar(newTasksGroup, SWT.HORIZONTAL | SWT.RIGHT);

    addTaskToolItem = new ToolItem(actionToolBar, SWT.PUSH | SWT.RIGHT);
    addTaskToolItem.setImage(new Image(display, TaskConsts.ICON_PLUS));

    final MainWindow mainWindow = this;
    addTaskToolItem.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            new CreateTask(getShell(), mainWindow);
        }
    });

    GridData gridData = new GridData();
    gridData.exclude = true;
    actionToolBar.setLayoutData(gridData);

    actionToolBar.pack();

    return actionToolBar;
}

private void organize() {
    GridLayout gridLayout = new GridLayout(2, false);
    shell.setLayout(gridLayout);
    shell.pack();
}

Thanks in advance~
Previous Topic:Drag and Drop in Swt TreeViewer?
Next Topic:Layout of Text
Goto Forum:
  


Current Time: Wed Feb 19 03:16:42 GMT 2020

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

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

Back to the top