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

The Archive Base Latest Questions

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

I set a margin for a panel in css. Now I need to get

  • 0

I set a margin for a panel in css. Now I need to get the margin width in GWT. How could I do this?
For example, I set a css style for the panel

   <ui:binder>
  .panel{
   margin: 5px;
   }


  <g:HTMLPanel Ui:field=myPanel styleName="{style.panel}" />   
  </ui:binder>

In GWT 2.4, how can I retrieve the margin value (5px) in GWT class.
I have tired these, DOM.getIntStyleAttribute(myPanel.getElement(), “margin”),
DOM.getIntStyleAttribute(myPanel.getElement(), “marginWidth”), and myPanel.getElement().getStyle().getMargin(). all of these return 0.

How can I get the margin width then?

Thanks for replying.

Regards

  • 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-03T14:02:21+00:00Added an answer on June 3, 2026 at 2:02 pm

    You’re looking for the computed style, but are requesting the element style.

    If you were to set the style attribute on an element directly, then you could query the element’s margin like you tried.

    <!-- style can only be set on html elements, not widgets -->
    <div ui:field="divElement" style='margin:5px'></div> 
    
    divElement.getStyle().getMargin();
    

    From what I could find, GWT does not provide a method for looking up the computed style. You will instead need to rely on an external library. A quick google search for gwt computed style will provide you with a few options.


    Alternatively, you could define the margin width as a GWT CSS constant and use a CssResource to access it.

    MyPanel.ui.xml

    <ui:style field="style" type="com.myproject.client.MyPanel.MyStyle">
      @def marginWidth 5px;
      .panel{ margin: marginWidth; }
    </ui:style>
    

    MyPanel.java

    @UiField MyStyle style;
    
    interface MyStyle extends CssResource {
      String marginWidth();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried to set the margin and border to 0,but still not working. <style
I'm working on this app, and I can't seem to get my margin to
I have ItemsControl with VirtualizingStackPanel as items panel like this: <ItemsControl Style={StaticResource ItemsControl} Name=itemsControl
My question is : I have an EditText and I want set a margin
I know that you can set the print margin in Eclipse, but if I
I want to get print out invoice but also wanna set margins and page
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
SET @v1 := SELECT COUNT(*) FROM user_rating; SELECT @v1 When I execute this query
I have a situation where i need to create a left panel. My manager
I have a set of buttons inside a stack panel. I want them all

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.