title: common properties of addStyleName() expressing over setStyleName() or even setStylePrimaryName()!
body: <p>I am new to GWT and was learning it through some examples running in Eclipse. In one of those programs for a button I added <code>setStyleName(class)</code> (also checked with <code>setStylePrimaryName()</code>) and added one more style to that using addStyleName(class).</p>
  
  <p>What I expected was that the button should display the css class properties setted using <code>setStyleName()</code>/setStylePrimaryname as this will be the primaryStylename.</p>
  
  <p>But to my surprise if I add another style to button using <code>addStyleName()</code>, that style is getting as the button's style eventhough it is its secondaryStyleName! In such a case inorder to express the primary styleName, I had to add the secondary style Name using <code>addStyleDependentName()</code>.</p>
  
  <p>My code sets styles as follows.</p>
  
  <pre><code>final Button sendButton=new Button("Send");
  final TextBox nameField=new TextBox();
  
  sendButton.setStylePrimaryName("newButton");
  sendButton.addStyleName("secondButton");
  </code></pre>
  
  <p>And in the css file </p>
  
  <pre><code> .newButton{
      display:block;
      font-size: 16pt;
      color: black;
      background-color: maroon;
  }
  .secondButton{
      color:blue;
      margin: 15px 10px 10px;
      background-color: olive;
  
  }
  </code></pre>
  
  <p>The button is always coming in olive background color except in cases where its adding as addStyleDependentName("secondButton") and </p>
  
  <p>case 2: while using <code>addStyleName("secondButton")</code> and then <code>setStyleName("newButton")</code> (As <code>setStyleName()</code> will remove the existing secondary styles). I had also checked the values of primary style name and others using <code>getStylePrimaryName()</code> and <code>getStyleName()</code>.</p>
  
  <p>getStylePrimaryName() gives "newButton" and getStyleName() gives newButton,secondButton....So even having a primary style name why its always showing its secondary style property(here secondButton) added through addStyleName()?</p>
  
  <p>*<strong><em>Please note: I have tried this on a text box as follows and its expressing the color mentioned under primary style as expected</em>*</strong></p>
  
  <pre><code>final TextBox nameField=new TextBox();
  nameField.setText("---Enter Name Here---");
  nameField.setStylePrimaryName("textStyle");
  nameField.addStyleName("myText");
  nameField.addStyleName("bigText");
  </code></pre>
  
  <p>and the CSS is as follows</p>
  
  <pre><code>.myText{
      color:blue;
  }
  
  .bigText{
      font-size: large;
  }
  .textStyle{
      color:maroon;
      text-shadow: aqua;
  
  }
  </code></pre>
  
  <p>A thing noticed was that unless we are not adding the secondary styles as addStyleDependentName(), the properties are displaying in the order in which class names occur in CSS...That is, if the primary style name definition comes after secondary ones, primary gets displayed, else the secondary ones...The difference can be noted changing the order in which classes are defined in CSS
  So in my button properties, when i changed the order to </p>
  
  <pre><code>.secondButton{
      color:blue;
      margin: 15px 10px 10px;
      background-color: olive;
  
  }
  
   .newButton{
      display:block;
      font-size: 16pt;
      color: black;
      background-color: maroon;
  }
  </code></pre>
  
  <p>the button color is getting as maroon. If the secondary styles are added as addStyleDependentName(), the primary style is expressed irrespective of the order in CSS</p>