Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to change the size of a Shell?
How to change the size of a Shell? [message #465550] |
Wed, 14 December 2005 21:57  |
Eclipse User |
|
|
|
Originally posted by: marygeng.hotmail.com
Hi, friends,
I am developing a plug-in and wants a dialog to be opened when a
button is clicked. However, when the dialog opens, it is too
small. I want to enlarge the size of the dialog by resizing the
Shell. But Shell.setSize(width,length) seems does not work.
My code is as follows:
final Shell shell =
new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
|SWT.APPLICATION_MODAL);
shell.setText("Connect to Server");
shell.setSize(500,200);
shell.setLayout(new GridLayout(2, true));
shell.setSize(500,200) has no effect on the size of the Shell. The
dialog remains the original small size.
Anyone knows what goes wrong here? Or some other methods to change the
size of a shell?
Thanks!
Lijuan
|
|
|
Re: How to change the size of a Shell? [message #465552 is a reply to message #465550] |
Thu, 15 December 2005 00:02   |
Eclipse User |
|
|
|
Lijuan,
It is correct method - you add any component in shell which change
size of shell - maybe jface dialog or similar
Lijuan wrote:
> Hi, friends,
> I am developing a plug-in and wants a dialog to be opened when a
> button is clicked. However, when the dialog opens, it is too
> small. I want to enlarge the size of the dialog by resizing the
> Shell. But Shell.setSize(width,length) seems does not work.
>
> My code is as follows:
>
> final Shell shell =
> new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
> |SWT.APPLICATION_MODAL);
>
> shell.setText("Connect to Server");
> shell.setSize(500,200);
> shell.setLayout(new GridLayout(2, true));
>
> shell.setSize(500,200) has no effect on the size of the Shell. The
> dialog remains the original small size.
>
> Anyone knows what goes wrong here? Or some other methods to change the
> size of a shell?
>
> Thanks!
>
> Lijuan
|
|
|
Re: How to change the size of a Shell? [message #465554 is a reply to message #465552] |
Wed, 14 December 2005 23:34   |
Eclipse User |
|
|
|
Originally posted by: marygeng.hotmail.com
I set labels,texts and buttons on the shell to form a dialog. But don't
want to use any predefined dialog class in Jface.
If the size of a text box can be changed, then the shell size might be
changed? But how to resize a text box?
Lijuan
Haris Peco wrote:
> Lijuan,
> It is correct method - you add any component in shell which change
> size of shell - maybe jface dialog or similar
>
> Lijuan wrote:
>
> > Hi, friends,
> > I am developing a plug-in and wants a dialog to be opened when a
> > button is clicked. However, when the dialog opens, it is too
> > small. I want to enlarge the size of the dialog by resizing the
> > Shell. But Shell.setSize(width,length) seems does not work.
> >
> > My code is as follows:
> >
> > final Shell shell =
> > new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
> > > SWT.APPLICATION_MODAL);
> >
> > shell.setText("Connect to Server");
> > shell.setSize(500,200);
> > shell.setLayout(new GridLayout(2, true));
> >
> > shell.setSize(500,200) has no effect on the size of the Shell. The
> > dialog remains the original small size.
> >
> > Anyone knows what goes wrong here? Or some other methods to change
> > the size of a shell?
> >
> > Thanks!
> >
> > Lijuan
|
|
|
Re: How to change the size of a Shell? [message #465566 is a reply to message #465554] |
Thu, 15 December 2005 08:59   |
Eclipse User |
|
|
|
Calling layout() on the composite containing the text box should
resize the text box to it's preferred size (based on your layout data).
"Lijuan" <marygeng@hotmail.com> wrote in message
news:dnqrov$auk$1@news.eclipse.org...
>I set labels,texts and buttons on the shell to form a dialog. But don't
> want to use any predefined dialog class in Jface.
>
> If the size of a text box can be changed, then the shell size might be
> changed? But how to resize a text box?
>
> Lijuan
>
> Haris Peco wrote:
>
>> Lijuan,
>> It is correct method - you add any component in shell which change
>> size of shell - maybe jface dialog or similar
>>
>> Lijuan wrote:
>>
>> > Hi, friends,
>> > I am developing a plug-in and wants a dialog to be opened when a
>> > button is clicked. However, when the dialog opens, it is too
>> > small. I want to enlarge the size of the dialog by resizing the
>> > Shell. But Shell.setSize(width,length) seems does not work.
>> >
>> > My code is as follows:
>> >
>> > final Shell shell =
>> > new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
>> > > SWT.APPLICATION_MODAL);
>> >
>> > shell.setText("Connect to Server");
>> > shell.setSize(500,200);
>> > shell.setLayout(new GridLayout(2, true));
>> >
>> > shell.setSize(500,200) has no effect on the size of the Shell. The
>> > dialog remains the original small size.
>> >
>> > Anyone knows what goes wrong here? Or some other methods to change
>> > the size of a shell?
>> >
>> > Thanks!
>> >
>> > Lijuan
>
|
|
|
Re: How to change the size of a Shell? [message #465572 is a reply to message #465550] |
Thu, 15 December 2005 09:18   |
Eclipse User |
|
|
|
The following works for me:
public static void main (String [] args) {
Display display = new Display ();
Shell parent = new Shell (display);
parent.setText("Parent shell");
parent.setSize(300, 300);
parent.open ();
final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE
|SWT.BORDER |SWT.APPLICATION_MODAL);
shell.setText("Connect to Server");
shell.setLayout(new GridLayout(2, true));
Label l = new Label(shell, SWT.NONE);
l.setText("click button to resize dialog");
l.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
Button b = new Button(shell, SWT.PUSH);
b.setText("resize dialog");
b.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
Point size = shell.getSize();
shell.setSize(size.x+10, size.y + 10);
}
});
shell.setSize(500,200);
shell.open();
while (!parent.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
"Lijuan" <marygeng@hotmail.com> wrote in message
news:dnqm2k$3pd$1@news.eclipse.org...
> Hi, friends,
> I am developing a plug-in and wants a dialog to be opened when a
> button is clicked. However, when the dialog opens, it is too
> small. I want to enlarge the size of the dialog by resizing the
> Shell. But Shell.setSize(width,length) seems does not work.
>
> My code is as follows:
>
> final Shell shell =
> new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
> |SWT.APPLICATION_MODAL);
>
> shell.setText("Connect to Server");
> shell.setSize(500,200);
> shell.setLayout(new GridLayout(2, true));
>
> shell.setSize(500,200) has no effect on the size of the Shell. The
> dialog remains the original small size.
>
> Anyone knows what goes wrong here? Or some other methods to change the
> size of a shell?
>
> Thanks!
>
> Lijuan
|
|
|
Re: How to change the size of a Shell? [message #465701 is a reply to message #465566] |
Mon, 19 December 2005 22:54  |
Eclipse User |
|
|
|
Originally posted by: marygeng.hotmail.com
Thanks, it works by calling:
text.setText("A String");
shell.layout();
The text box will be resized to the prefered size.
However, "A String" does not appear in the text box as default value,
why? and how to set a default value in a text box?
Thanks,
Lijuan
Gail Jakubowski wrote:
> Calling layout() on the composite containing the text box should
> resize the text box to it's preferred size (based on your layout
> data).
>
> "Lijuan" <marygeng@hotmail.com> wrote in message
> news:dnqrov$auk$1@news.eclipse.org...
> > I set labels,texts and buttons on the shell to form a dialog. But
> > don't want to use any predefined dialog class in Jface.
> >
> > If the size of a text box can be changed, then the shell size might
> > be changed? But how to resize a text box?
> >
> > Lijuan
> >
> > Haris Peco wrote:
> >
> > > Lijuan,
> >> It is correct method - you add any component in shell which change
> > > size of shell - maybe jface dialog or similar
> > >
> > > Lijuan wrote:
> > >
> >>> Hi, friends,
> >>> I am developing a plug-in and wants a dialog to be opened when a
> >>> button is clicked. However, when the dialog opens, it is too
> >>> small. I want to enlarge the size of the dialog by resizing the
> >>> Shell. But Shell.setSize(width,length) seems does not work.
> > > >
> >>> My code is as follows:
> > > >
> >>> final Shell shell =
> >>> new Shell(parent, SWT.DIALOG_TRIM | SWT.TITLE |SWT.BORDER
> >>> > SWT.APPLICATION_MODAL);
> > > >
> >>> shell.setText("Connect to Server");
> >>> shell.setSize(500,200);
> >>> shell.setLayout(new GridLayout(2, true));
> > > >
> >>> shell.setSize(500,200) has no effect on the size of the Shell. The
> >>> dialog remains the original small size.
> > > >
> >>> Anyone knows what goes wrong here? Or some other methods to change
> >>> the size of a shell?
> > > >
> >>> Thanks!
> > > >
> >>> Lijuan
> >
|
|
|
Goto Forum:
Current Time: Thu Jul 03 19:42:45 EDT 2025
Powered by FUDForum. Page generated in 0.25142 seconds
|