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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:04:36+00:00 2026-05-27T07:04:36+00:00

I have some code in HTML and CSS where HTML looks like this: <div

  • 0

I have some code in HTML and CSS where HTML looks like this:

<div id="avmenu">
<h2 class="hide">Menu:</h2>
<ul>
<li><a href="#">Welcome!</a></li>

And my CSS looks like this:

#avmenu
{
Style details
}

#avmenu li a:hover
{
Style details
}

a:hover{ Hover styles }

So above piece of code shows a menu item and does some animation like color change etc when you hover your mouse over the menu. I have show bare minimum styles sufficient to explain problem at hand.

Now when I migrate this to GWT. We have used Label as menu items, and I want to achieve same effect in GWT too. Here is what I have tried

  1. I tried to apply CSS Style named “avmenu”, this applied basic styles, but of course didn’t get animation
  2. Then I tried DOM.setElementAttribute(orgLbl.getElement(), "id", "avmenu"); but that also didn’t help.

What would be my best option with minimal time and effort to achieve same effect? I can of course listen to events on Label and then change the style, but doing that for all of the widgets would be an overkill!

EDIT- More info: I am building Menu using Label, and adding that to tree

userMgmtLbl = new Label("User mgmt");
userMgmtLbl.setStyleName(HOME_MENU_LBL_STYLE);
treeItem_1 = configParentTL.addItem(userMgmtLbl);
userMgmtLbl.addClickHandler(Click logic)

  • 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-27T07:04:37+00:00Added an answer on May 27, 2026 at 7:04 am

    One of the problems that you’re running into is that Tree and TreeItem in GWT are composed of arbitrary divs, rather than ul and li as in your original html. (When indoubt you can inspect the DOM of GWT’s showcase to see how the underlying widgets are created).

    What this means is that your selectors, such as “#avmenu li a:hover” will no longer work.

    If your navigation menu is static, your best bet is probably to use GWT ui-binders, which are basically gwts templating system. If you use a HTMLPanel as your root widget, you can effectively use all your original HTML verbatim and not worry about trying to mash all the DOM elements into corresponding widgets.

    A basic widget would look something like this:

    NavigationWidget.java
    public final class YourWidget extends Composite {

      YourWidget() {
        initWidget(binder.createAndBindUi(this));
      }
    
      private static final Binder binder = GWT.create(Binder.class);
      interface Binder extends UiBinder<Widget, YourWidget> {}
    }
    

    NavigationWidget.ui.xml

    <ui:UiBinder
       xmlns:gwt="urn:import:com.google.gwt.user.client.ui"
       xmlns:ui="urn:ui:com.google.gwt.uibinder">
    
      <gwt:HTMLPanel>
        <div id="avmenu">
          <h2 class="hide">Menu:</h2>
          <ul>
          <li><a href="#">Welcome!</a></li>
        </div>
      </gwt:HTMLPanel>
    
    </ui:UiBinder>
    

    As an aside, in this example HTMLPanel adds a DIV of its own to the DOM, making the second div a bit redundant. Unfortunately, widgets in gwt don’t have an easy way of setting the ID attribute from templates, so you’re stuck with the second div unless you want to switch your #avmenu selector to .avmenu

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

Sidebar

Related Questions

I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have some HTML that looks like this: <h2>Heading</h2> <div class='myClass'> <h2>Another Heading</h2> </div>
I have HTML that looks like this: <div class=item-list> <h3>Monday Sep 21</h3> <h3>Tuesday Sep
Let's say I have some code like this: <html> <head><title>Title</title></head> <body> <?php if (!$someCondition){
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a menu that contains submenus. Its HTML source looks like this: <ul
I have the following code for showing some images: HTML: <div class=footer-logos> <ul> <li><img
I have the following HTML / CSS: <table> <tr> <td> <div> <pre> <code> This
I have this HTML file with some CSS styles, now I am trying to
I have inherited some HTML code and have been asked to align the two

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.