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

  • Home
  • SEARCH
  • 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 908965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:48:00+00:00 2026-05-15T16:48:00+00:00

i wrote a code to zoom in, and zoom out an image using smartGWT.

  • 0

i wrote a code to zoom in, and zoom out an image using smartGWT. but the problem is that the including canvas can’t show it’s scroll bars how to solve that

public class ImageViewer implements EntryPoint {

static int counter = 0;
int widths[] = new int[5];
int hights[] = new int[5];
int originalW=0;
int originalH=0;

public void onModuleLoad() {
    // -------tool bar ---------------
    ToolStrip toolbar = new ToolStrip();  
    toolbar.setWidth("100%"); 
    toolbar.addFill();

    ToolStripButton max = new ToolStripButton("  +  ");
    ToolStripButton min = new ToolStripButton("  -  ");
    ToolStripButton auto = new ToolStripButton(" auto ");

    ToolStripButton print = new ToolStripButton(" print ");
    ToolStripButton save = new ToolStripButton(" save ");

    toolbar.addButton(max);
    toolbar.addButton(min);
    toolbar.addButton(auto);

    toolbar.addSeparator();

    toolbar.addButton(print);
    toolbar.addButton(save);
    // -------------------------------
    HLayout hLayout = new HLayout();
    VLayout vLayout = new VLayout();


    SectionStack sectionStack = new SectionStack();
    sectionStack.setWidth("100%");
    sectionStack.setHeight("100%");
    sectionStack.setVisibilityMode(VisibilityMode.MULTIPLE);
    sectionStack.setAnimateSections(true);
    sectionStack.setOverflow(Overflow.HIDDEN);

    SectionStackSection summarySection = new SectionStackSection();
    summarySection.setTitle("Image Viewer");
    summarySection.setExpanded(true);
    summarySection.setItems(hLayout);

    sectionStack.setSections(summarySection);

    TreeGrid treeGrid = new TreeGrid();
    treeGrid.setWidth("20%");
    treeGrid.setShowConnectors(true);
    treeGrid.setShowResizeBar(true);


    final Canvas imgCanvas = new Canvas();
    imgCanvas.setShowEdges(true);

    final Img img = new Img("http://www.google.com/intl/en_ALL/images/srpr/logo1w.png");
    img.setParentElement(imgCanvas);
    img.draw();
    img.setImageType(ImageStyle.CENTER);
    originalW = img.getWidth();
    originalH = img.getHeight();
    widths[0] = originalW;
    hights[0] = originalH;

    widths[1] = widths[0]*2;
    hights[1] = hights[0]*2;

    widths[2] = widths[1]*2;
    hights[2] = hights[1]*2;

    widths[3] = widths[2]*2;
    hights[3] = hights[2]*2;

    widths[4] = widths[3]*2;
    hights[4] = hights[3]*2;



    hLayout.setMembers(treeGrid, vLayout);
    vLayout.setMembers(toolbar,imgCanvas);

    RootPanel.get("imgPanel").add(sectionStack);


    //-------------- handelers --------------------

    max.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            img.setImageType(ImageStyle.STRETCH);
            if (counter <4){
                counter++;
                img.animateRect(0, 0, widths[counter] , hights[counter]);   
            }
        }
    });

    min.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            img.setImageType(ImageStyle.STRETCH);
            if (counter > 0){
                counter--;
                img.animateRect(0, 0, widths[counter], hights[counter]);
            }               
        }
    });

    auto.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            img.setImageType(ImageStyle.CENTER);
            img.animateRect(0, 0, originalW, originalH);
            imgCanvas.adjustForContent(true);

        }
    });
    //---------------------------------------------
}

}

  • 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-05-15T16:48:01+00:00Added an answer on May 15, 2026 at 4:48 pm

    imgCanvas.setOverflow(Overflow.AUTO). imgCanvas will then show scrollbars as necessary if the Img is larger than the imgCanvas’ specified size.

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

Sidebar

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.