no spacing on H layout; boxes always checked

I wrote the following:

package com.accesspoint.vaadin3;

import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@Theme("mytheme")
public class HLTest extends UI
{
    private static String SHOW_MRC_COSTS        = "Display MRC Margin & Cost";
    private static String SHOW_NRC_CHARGES      = "Display NRCs";
    @Override
    protected void init(VaadinRequest request) 
    {
        final VerticalLayout pageLayout = new VerticalLayout();
        
        CheckBox showCostCheckBox    = new CheckBox(SHOW_MRC_COSTS);
        CheckBox showNrcCheckBox     = new CheckBox(SHOW_NRC_CHARGES);
        showCostCheckBox.setValue(false);
        showNrcCheckBox.setValue(false);
        
        Layout checkBoxLayout = new VerticalLayout();
        checkBoxLayout.addComponents(showCostCheckBox, showNrcCheckBox);
        
        HorizontalLayout    hl = new HorizontalLayout();
        Label               l  = new Label("1st component");
        CheckBox            cb = new CheckBox("2nd component");
        hl.addComponents(l, checkBoxLayout, cb);
        
        pageLayout.addComponents(hl);
        
        setContent(pageLayout);
    }
}

Did a clean and build within netbeans (can’t find the maven build “run as” options), and get output as in the attachment (sorry, don’t have a server to put it on). There is no space at all between the components horizontally, but more frustrating is that the checkboxes are all checked, and I cannot uncheck them by clicking on them.

This can’t be the default. If I remove the “@Theme” line, I get much smaller components that work properly and have a little space between them.

What am I missing?

28708.png

You sould set spacing to true

hl.setSpacing(true);

Regards

ok. any hint on the checkboxes?

I’m not sure. Checkbox should be unchecked by default. This line is not necessary

showCostCheckBox.setValue(false); showNrcCheckBox.setValue(false); Did you developed the theme mytheme? if not try using some default theme like valo

@Theme("valo")

Yeah, valo is the theme that ‘mytheme’ imports. Here’s the entirety of the mytheme.scss I have:

@import "../valo/valo.scss";

@mixin mytheme {
  @include valo;

  // Insert your own theme rules here
  .v-label-hideThis {
      display: none
  }
  
  .v-label-pricingtablecost {
      font-size: 11px;
  }
  
  .v-label-nrcfigures {
      font-size: 11px;
  }
  
  .pricingtable .v-table-row-odd {
      background-color: white;
  }
  
  .v-verticallayout-margin {
      padding: 50 px;
  }
}

(I took out all the commented-out lines at the start; hopefully they don’t do anything)

Whether I use @Theme(“mytheme”) or @Theme(“valo”) the result is the same; the checkboxes are checked and remain that way regardless of what I click on.

I just tested your code and it works just fine as you can see on photos
28710.png
28711.png

package com.example;
/** * Created by ivan on 10/28/16. */
import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@SpringUI @Theme("valo")
public class HLTest extends UI {
private static String SHOW_MRC_COSTS = "Display MRC Margin & Cost";
private static String SHOW_NRC_CHARGES = "Display NRCs";

@Override
protected void init(VaadinRequest request) {

final VerticalLayout pageLayout = new VerticalLayout();
CheckBox showCostCheckBox = new CheckBox(SHOW_MRC_COSTS);
CheckBox showNrcCheckBox = new CheckBox(SHOW_NRC_CHARGES);
showCostCheckBox.setValue(false); showNrcCheckBox.setValue(false);

Layout checkBoxLayout = new VerticalLayout();
checkBoxLayout.addComponents(showCostCheckBox, showNrcCheckBox);

HorizontalLayout hl = new HorizontalLayout();
Label l = new Label("1st component");
CheckBox cb = new CheckBox("2nd component");
hl.addComponents(l, checkBoxLayout, cb);
hl.setSpacing(true); pageLayout.addComponents(hl);

pageLayout.setMargin(true); setContent(pageLayout);
}
}

Well, thanks for the effort and the notification; wonder what strange thing I’ve got in my environment/code/head/whatever that causes this. If I figure out an actual cause I’ll post back…