• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

set primaryStyleName and css

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when create project, the css file already contains some predefined css class like
.gwt_VerticalSplitPanel .splitter{
......
}

but is it necessary to explicit call the

when create a VerticalSplitPanel?

I have this doubt because I found sometimes even the widget (e.g. treee, treeitem) has not explicit call setStylePrimaryName, it can still automatically refer to the corresponding css class in css file,
but some cannot (like gwt-HorizontalPanel).
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These components call the setStyleName("styleName") when they are initialized. You do not need to make explicit calls yourself.
 
peter tong
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:These components call the setStyleName("styleName") when they are initialized. You do not need to make explicit calls yourself.



I found it quite confusing.
when new a gwt project, the default css file has some style class for some component but not all.
for example, TabBar has corresponding css class in css file as follow:


but some component like DockPanel has no default css class in the css file.
if I add the style class in css as follow:


and then write the following code:


I found the following result


tabBar1.getStylePrimaryName() = gwt-TabBar
dockPanel1 primaryStyleName =
dockPanel1 primaryStyleName = gwt-DockPanel



that is, if the css file default has that classname, then when create the widget, the component will automatically set their stylePrimaryName corresponding to the css file,
but if the widget has no default css style class in css file and we add it manually, then even using their naming convention "gwt-"+ WidgetName, the widget still cannot automatically set
their stylePrimaryName.

is it normal behavior of gwt?
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not all widgets use primary styles, in particular many panel types. For HorizontalPanel, there is nothing that would need to be set for its style for general use. And it wouldn't necessarily be good for Google to have set a primary style, since the same class might be used multiple times within an app for totally different purposes. BTW, the Javadocs usually list the styles used by a widget (but unfortunately, not always). But, if there is no rule in the CSS, then GWT isn't going to bother setting a primary style.

If you want a primary style for a DockPanel, you can either manually set it for each instance, as you did, or extend DockPanel with a new class that sets its own primary style with its own name.
 
peter tong
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


or extend DockPanel with a new class that sets its own primary style with its own name.



Possible to set primary stlye with class?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic