Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to control shell size?
How to control shell size? [message #461437] Thu, 22 September 2005 18:24 Go to next message
Eclipse UserFriend
Originally posted by: cix.ptoye.com

Another newbie question, so probably a silly one.

I'm trying to build an SWT app which does its output into a text box. I
don't know how much output there will be in advance, so I'm giving the box
scroll bars. If I don't do anything about the size, it just goes on
expanding downwards with the scroll bars greyed out, and the shell expands
with it until it's taller than the screen, which makes it virtually
impossible to read the text.

If I set the size of the text box each time with code like:

/*
call a subroutine which calls outputText.append several times
*/
textSize=outputText.computeSize(SWT.DEFAULT,SWT.DEFAULT);
textW=Math.min(textSize.x,400);
textH=Math.min(textSize.y,400);
outputText.setSize(textW,textH);
shell.pack(true);
System.out.println("Shell size "+ shell.getSize().y +
", table size " + outputText.getSize().y);

the shell window keeps on expanding each time I call the subroutine until
it's 780 pixels high and the text box 569 pixels. Then the text box goes
down to 400 high and displays a scroll bar but the shell window stays at
780, which is too big for the physical display. Resizing the window does
odd things to the table, which I'm still trying to work out.

Any idea what I'm doing wrong?


Peter
Re: How to control shell size? [message #461454 is a reply to message #461437] Fri, 23 September 2005 12:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Hi Peter,

two possible solutions:
(a) you should have a look into the layout concept of SWT (see articles
in http://www.eclipse.org/articles/). You should use a GidLayout and
give your Text widget a hightHint.

(b) do not use shell.pack but simply shell.setSize(blabla).

Hope that helped,
Friederich

Peter Toye wrote:
> Another newbie question, so probably a silly one.
>
> I'm trying to build an SWT app which does its output into a text box. I
> don't know how much output there will be in advance, so I'm giving the box
> scroll bars. If I don't do anything about the size, it just goes on
> expanding downwards with the scroll bars greyed out, and the shell expands
> with it until it's taller than the screen, which makes it virtually
> impossible to read the text.
>
> If I set the size of the text box each time with code like:
>
> /*
> call a subroutine which calls outputText.append several times
> */
> textSize=outputText.computeSize(SWT.DEFAULT,SWT.DEFAULT);
> textW=Math.min(textSize.x,400);
> textH=Math.min(textSize.y,400);
> outputText.setSize(textW,textH);
> shell.pack(true);
> System.out.println("Shell size "+ shell.getSize().y +
> ", table size " + outputText.getSize().y);
>
> the shell window keeps on expanding each time I call the subroutine until
> it's 780 pixels high and the text box 569 pixels. Then the text box goes
> down to 400 high and displays a scroll bar but the shell window stays at
> 780, which is too big for the physical display. Resizing the window does
> odd things to the table, which I'm still trying to work out.
>
> Any idea what I'm doing wrong?
>
>
> Peter


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Re: How to control shell size? [message #461460 is a reply to message #461454] Fri, 23 September 2005 18:17 Go to previous message
Eclipse UserFriend
Originally posted by: cix.ptoye.com

In article <dh0tts$c5l$1@news.eclipse.org>, friederich@kupzog.de
(Friederich Kupzog) wrote:

> *From:* Friederich Kupzog <friederich@kupzog.de>
> *Date:* Fri, 23 Sep 2005 14:54:16 +0200
>
> Hi Peter,
>
> two possible solutions:
> (a) you should have a look into the layout concept of SWT (see articles
> in http://www.eclipse.org/articles/). You should use a GidLayout and
> give your Text widget a hightHint.
>
> (b) do not use shell.pack but simply shell.setSize(blabla).
>
> Hope that helped,
> Friederich
>
> Peter Toye wrote:
> > Another newbie question, so probably a silly one.
> >
> > I'm trying to build an SWT app which does its output into a text box.
> > I don't know how much output there will be in advance, so I'm giving
> > the box scroll bars. If I don't do anything about the size, it just
> > goes on expanding downwards with the scroll bars greyed out, and the
> > shell expands with it until it's taller than the screen, which makes
> > it virtually impossible to read the text.
> >
> > If I set the size of the text box each time with code like:
> >
> > /*
> > call a subroutine which calls outputText.append several times
> > */
> > textSize=outputText.computeSize(SWT.DEFAULT,SWT.DEFAULT);
> > textW=Math.min(textSize.x,400);
> > textH=Math.min(textSize.y,400);
> > outputText.setSize(textW,textH);
> > shell.pack(true);
> > System.out.println("Shell size "+ shell.getSize().y +
> > ", table size " + outputText.getSize().y);
> >
> > the shell window keeps on expanding each time I call the subroutine
> > until it's 780 pixels high and the text box 569 pixels. Then the text
> > box goes down to 400 high and displays a scroll bar but the shell
> > window stays at 780, which is too big for the physical display.
> > Resizing the window does odd things to the table, which I'm still
> > trying to work out.
> >
> > Any idea what I'm doing wrong?
> >
> >
> > Peter
>
>
> --
> Friederich Kupzog
> Elektronik & Software
> Neusser Str. 5-7
> 50670 K
Previous Topic:Newcomer:
Next Topic:Multiline text in Table
Goto Forum:
  


Current Time: Thu Mar 28 18:07:10 GMT 2024

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

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

Back to the top