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 9248257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:54:21+00:00 2026-06-18T09:54:21+00:00

I have SWT application which uses map service API ( http://mapy.cz particularly) for acquiring

  • 0

I have SWT application which uses map service API (http://mapy.cz particularly) for acquiring image as background for some additional drawings based on that provided map data.

Before the browser component screenshot is made by SWT GC instance, I’m trying to hide the controls from map layer, to have it cleanest as possible. This functionality is provided by service’s JS API this way:

function hideControls() {
    var controls = map.getControls();
    for (var i = controls.length; i > 0; i--) {
        map.removeControl(controls[i]);
    }
    //alert('test');
}

This works absolutely flawless in all desktop browsers by calling hideControls() function from console.

But if the method is called by SWT Browser component by

browser.evaluate("hideControls();"); 

it just do not work until the alert() function (as commented right now) is uncommented. Then alert dialog is shown and controls hidden as they should be.

Any idea why alert() method call cause correct working of that JavaScript function?

EDIT

Some additional code context

browser.evaluate("hideControls();");
// ugly ie scroll bar force workaround
// calls JS methods which returns size of map content in browser component
Double mapWidth = (Double) browser.evaluate("return getSizeX();");
Double mapHeight = (Double) browser.evaluate("return getSizeY();");
// creates new canvas
GC gc = new GC(browser);
// do the screenshot
capturedImage = new Image(display, mapWidth.intValue(), mapHeight.intValue());
gc.copyArea(capturedImage, 0, 0);
// cleanout
gc.dispose();

JavaScript methods for map size calculation (provided by JS API for map service)

function getSizeX() {
    return map.getSize().x;
}
function getSizeY() {
    return map.getSize().y;
}

EDIT2

After some deeper debug the method which removes controls from map layer is

SMap.prototype.removeControl = function (a) {
    var b = this.controls.indexOf(a); 
    - 1 != b && ((a = a.getContainer()) && this.controlLayer.removeItem(a), this.controls.splice(b, 1))
};

So for instance (for HUD control)

SMap.Layer.HUD.prototype.removeItem = function (a) {
    a.parentNode.removeChild(a)
};

That means it directly change the DOM tree, though it’s not asynchronous..

  • 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-18T09:54:22+00:00Added an answer on June 18, 2026 at 9:54 am

    As Sean Kinsey hinted it’s really problem of browser component, that needs to be stalled until JavaScript thread finishes all necessary steps.

    I’ve found workaround, cause in SWT GUI components have to take care about their event handling themselves, it’s though possible to stall the browser until JavaScript finishes.

    browser.evaluate("hideControls();");
    for(int i = 0; i < 20; i++) {
        if(!display.readAndDispatch()); display.sleep();
    }
    

    It’s ugly workaround, but 20 ‘ticks’ for browser to do some trivial DOM manipulation should be enough (I hope).

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

Sidebar

Related Questions

I have created an test swt application which has some German special characters. When
I have an Android application, which uses javax.crypto to encrypt some text data in
i have an SWT Application which uses RMI. Only on mac/cocoa it won't shut
I'm designing a Java application using SWT. I have some tables which will display
I am building an application in swt, I also have a thread running which
Hi all i am developing an application in swt in which i have the
I have an SWT application which is quite complex at the moment. And I
I am working on SWT based GUI application. I have one object variable which
I have an SWT/JFace application that uses the Realm (not sure of the concept)
I am trying to communicate with Excel from a Java/SWT application. I have been

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.