Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:24:06+00:00 2026-06-18T14:24:06+00:00

I want to export a full scrolled composite to an image. I mean the

  • 0

I want to export a full scrolled composite to an image. I mean the whole composite, not just the visible area of the composite.
I found this example:

        Image drawable = new Image(display, someComposite.getBounds());
        GC gc = new GC(drawable);
        mainWidget.print(gc);
        ImageLoader loader = new ImageLoader();
        loader.data = new ImageData[] {drawable.getImageData()};
        loader.save("exportedImage.bmp", SWT.IMAGE_BMP);
        drawable.dispose();
        gc.dispose(); 

but the output is the visible area of the scrolled composite. 🙁 and not whole of it, I guess that because of the .getBound() method, but I cant find a way to switch it to another method. I tried .getClientArea() but it didn’t worked…

Thanks in advance,
Yossi.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:24:07+00:00Added an answer on June 18, 2026 at 2:24 pm

    I found an example and modified some stuff – just copy & paste it:

    import org.eclipse.swt.*;
    import org.eclipse.swt.custom.ScrolledComposite;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Color;
    import org.eclipse.swt.graphics.GC;
    import org.eclipse.swt.graphics.Image;
    import org.eclipse.swt.graphics.ImageData;
    import org.eclipse.swt.graphics.ImageLoader;
    import org.eclipse.swt.graphics.Rectangle;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.*;
    
    
    public class ScroledCompositeExport {
        public static void main (String [] args) {
            final Display display = new Display ();
         Shell shell = new Shell(display);
            shell.setLayout(new FillLayout());
            shell.setSize(200, 200);
            shell.setLocation(20, 20);
    
            final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER  | SWT.V_SCROLL | SWT.H_SCROLL);
            sc.setLayout(new GridLayout(1,true));
    
            final Composite innerComposite = new Composite(sc, SWT.NONE);
            innerComposite.setSize(400, 400);
            innerComposite.setLayout(new GridLayout(1, true));
            innerComposite.setBackground(new Color(display, 255, 0, 0));
    
            for(int i = 0; i < 10; i++)
            {
                    Button b = new Button(innerComposite, SWT.PUSH);
                    b.setText("Text");
                    b.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) 
                        {
                            Image image = new Image(display, innerComposite.getBounds().width, innerComposite.getBounds().height);
                            ImageLoader loader = new ImageLoader();
    
                            GC gc = new GC(image);
                            innerComposite.print(gc);
    
                            gc.dispose();
    
                            loader.data = new ImageData[]{image.getImageData()};
                            loader.save("c:/temp/out.png", SWT.IMAGE_PNG);
                        }
                    });
            }
    
            sc.setMinSize(innerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            sc.setContent(innerComposite);
            sc.setExpandHorizontal(true);
            sc.setExpandVertical(true);
    
            shell.open();
            shell.open ();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch ()) display.sleep ();
            }
            display.dispose ();
        }
    }
    

    It’s working 🙂
    and can be good point to start from.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to export a XtraGrid as an image. Pratically i need something like
Now I want to export a image in my Project to a folder ,
I want to export a custom XML feed from Magento, and this is the
I want to export some classes, say, Dog and Cat . One way to
I want to export TVP (Type of DataTable) to .csv file, or .xls, but
I want to export my simple application in xcode 4.33 But I failed to
I want to export the assemblies built in my project. But where are they
I want to export the audio-media of a MOV-File with the QuickTime-API and save
I want to export jar file with existing jar file in the project by
I am want to export database table to a file. I am using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.