ScrolledComposite problems!!! [message #443924] |
Mon, 04 October 2004 15:43 |
Eclipse User |
|
|
|
Originally posted by: nomelody.gmx.net
Hi all, Im having great difficulties getting a ScrolledComposite to work.
Im pretty sure I've set it up correctly but yet NO Scrollbars!! this is
very frustrating, can anybopdy help please :) I want to display a large
image in a smallish window so you can then scroll about the window to see
the image. Heres a code snippit... Thanks in advance :)
sc = new ScrolledComposite( parent, SWT.CENTER | SWT.H_SCROLL |
SWT.V_SCROLL );
c1 = new Composite( sc, SWT.NONE );
sc.setContent( c1 );
c1.setLayout( new FillLayout() );
chartLabel = new Label( c1, SWT.CENTER );
chartLabel.setImage( this.getBigImage() );
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setMinSize( c1.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
c1.layout();
|
|
|
Re: ScrolledComposite problems!!! [message #443933 is a reply to message #443924] |
Mon, 04 October 2004 16:56 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
Your code worked for me in the following snippet. What is the layout on
"parent"? What are you seeing (i.e. Does the image show up at all? Is it
clipped but there are no scrollbars?)
public static void main (String [] args) {
Display display = new Display ();
Image bigImage = new Image(display,
Newsgroup.class.getResourceAsStream("../images/alaska.bmp"));
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
ScrolledComposite sc = new ScrolledComposite(shell, SWT.CENTER |
SWT.H_SCROLL | SWT.V_SCROLL );
Composite c1 = new Composite( sc, SWT.NONE );
sc.setContent( c1 );
c1.setLayout( new FillLayout() );
Label chartLabel = new Label( c1, SWT.CENTER );
chartLabel.setImage(bigImage);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setMinSize( c1.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
c1.layout();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
"SteveF" <nomelody@gmx.net> wrote in message
news:cjrr36$tas$1@eclipse.org...
> Hi all, Im having great difficulties getting a ScrolledComposite to work.
> Im pretty sure I've set it up correctly but yet NO Scrollbars!! this is
> very frustrating, can anybopdy help please :) I want to display a large
> image in a smallish window so you can then scroll about the window to see
> the image. Heres a code snippit... Thanks in advance :)
>
> sc = new ScrolledComposite( parent, SWT.CENTER | SWT.H_SCROLL |
> SWT.V_SCROLL );
>
> c1 = new Composite( sc, SWT.NONE );
>
> sc.setContent( c1 );
>
> c1.setLayout( new FillLayout() );
>
> chartLabel = new Label( c1, SWT.CENTER );
>
> chartLabel.setImage( this.getBigImage() );
>
> sc.setExpandHorizontal(true);
> sc.setExpandVertical(true);
> sc.setMinSize( c1.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
>
> c1.layout();
>
|
|
|
Re: ScrolledComposite problems!!! [message #444066 is a reply to message #443933] |
Wed, 06 October 2004 13:30 |
Eclipse User |
|
|
|
Originally posted by: nomelody.gmx.net
Thanks Veronika , I got it working in the end. the parent controll was a
tabbed pane and i needed to set the layout to FillLayout. Cheers :)
Veronika Irvine wrote:
> Your code worked for me in the following snippet. What is the layout on
> "parent"? What are you seeing (i.e. Does the image show up at all? Is it
> clipped but there are no scrollbars?)
> public static void main (String [] args) {
> Display display = new Display ();
> Image bigImage = new Image(display,
> Newsgroup.class.getResourceAsStream("../images/alaska.bmp"));
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> ScrolledComposite sc = new ScrolledComposite(shell, SWT.CENTER |
> SWT.H_SCROLL | SWT.V_SCROLL );
> Composite c1 = new Composite( sc, SWT.NONE );
> sc.setContent( c1 );
> c1.setLayout( new FillLayout() );
> Label chartLabel = new Label( c1, SWT.CENTER );
> chartLabel.setImage(bigImage);
> sc.setExpandHorizontal(true);
> sc.setExpandVertical(true);
> sc.setMinSize( c1.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
> c1.layout();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> "SteveF" <nomelody@gmx.net> wrote in message
> news:cjrr36$tas$1@eclipse.org...
> > Hi all, Im having great difficulties getting a ScrolledComposite to work.
> > Im pretty sure I've set it up correctly but yet NO Scrollbars!! this is
> > very frustrating, can anybopdy help please :) I want to display a large
> > image in a smallish window so you can then scroll about the window to see
> > the image. Heres a code snippit... Thanks in advance :)
> >
> > sc = new ScrolledComposite( parent, SWT.CENTER | SWT.H_SCROLL |
> > SWT.V_SCROLL );
> >
> > c1 = new Composite( sc, SWT.NONE );
> >
> > sc.setContent( c1 );
> >
> > c1.setLayout( new FillLayout() );
> >
> > chartLabel = new Label( c1, SWT.CENTER );
> >
> > chartLabel.setImage( this.getBigImage() );
> >
> > sc.setExpandHorizontal(true);
> > sc.setExpandVertical(true);
> > sc.setMinSize( c1.computeSize(SWT.DEFAULT, SWT.DEFAULT) );
> >
> > c1.layout();
> >
|
|
|
Powered by
FUDForum. Page generated in 0.58356 seconds