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] |
Thu, 15 December 2005 02: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 05:02 |
Haris Peco Messages: 1072 Registered: July 2009 |
Senior Member |
|
|
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] |
Thu, 15 December 2005 04: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 13:59 |
Gail Jakubowski Messages: 36 Registered: July 2009 |
Member |
|
|
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 14:18 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
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] |
Tue, 20 December 2005 03: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 Dec 05 16:34:37 GMT 2024
Powered by FUDForum. Page generated in 0.03538 seconds
|