Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dialog resize in SWT  RSS feed

 
Chethan Sharma
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a composite in a dialog.
I want to resize the dialog and when the dialog is resizing i want to update the composite accordigly.
I am using SWT.RESIZE | SWT.MAX for the dialog which is ok.
How do I set the resizing of the composite also?

To resize the dialog:
===============
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX
| SWT.APPLICATION_MODAL);

how to resize the composite :
=======================

protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
final GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);

final Composite composite = new Composite(container, SWT.NONE);
final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
gridData.heightHint = 378;
gridData.widthHint = 667;
composite.setLayoutData(gridData);
----
----
table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setBounds(19, 93, 645, 280);

final TableColumn mibNameColumn = new TableColumn(table, SWT.NONE);

and using six columns in a table.
Please let me know how to handle this one.
 
Chethan Sharma
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please can some one help me from this.
 
Chethan Sharma
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the below code i am able to resize the dialog and composite but scroll bar is not coming.
Please let me know how to get scrollbar.


final GridLayout gridLayout = new GridLayout();
container.setLayout(gridLayout);
//container.setLayout(new GridLayout(1,false)); final Composite composite = new Composite(container, SWT.NONE);
final GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);

comp.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Rectangle area = comp.getClientArea();
Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - 2*table.getBorderWidth();
if (preferredSize.y > area.height + table.getHeaderHeight()) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required
Point vBarSize = table.getVerticalBar().getSize();
width -= vBarSize.x;
}
Point oldSize = table.getSize();
if (oldSize.x > area.width) {
// table is getting smaller so make the columns // smaller first and then resize the table to
// match the client area width
column1.setWidth(width/3);
column2.setWidth(width - column1.getWidth());
table.setSize(area.width, area.height);
} else {
// table is getting bigger so make the table // bigger first and then make the columns wider
// to match the client area width
table.setSize(area.width, area.height);
column1.setWidth(width/3);
column2.setWidth(width - column1.getWidth());
}
}
});
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!