Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScrolledComposite problems!!!
ScrolledComposite problems!!! [message #443924] Mon, 04 October 2004 15:43 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
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 Go to previous message
Eclipse UserFriend
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();
> >
Previous Topic:swt component in java plugin
Next Topic:Set focus on specific tab
Goto Forum:
  


Current Time: Tue Oct 20 17:16:16 GMT 2020

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

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

Back to the top