com.vaadin.ui.Label.setPrimaryStyleName()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(14.5k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.vaadin.ui.Label.setPrimaryStyleName()方法的一些代码示例,展示了Label.setPrimaryStyleName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.setPrimaryStyleName()方法的具体详情如下:
包路径:com.vaadin.ui.Label
类名称:Label
方法名:setPrimaryStyleName

Label.setPrimaryStyleName介绍

暂无

代码示例

代码示例来源:origin: vaadin/material-theme-fw8

public void setTheme(boolean lightTheme) {
  super.setTheme(lightTheme);
  primary.setPrimaryStyleName(lightTheme ? Typography.Dark.Subheader.PRIMARY : Typography.Light.Subheader.PRIMARY);
  secondary.setPrimaryStyleName(lightTheme ? Typography.Dark.Body1.SECONDARY : Typography.Light.Body1.SECONDARY);
}

代码示例来源:origin: vaadin/material-theme-fw8

public void setTheme(boolean lightTheme) {
  super.setTheme(lightTheme);
  primary.setPrimaryStyleName(lightTheme ? Typography.Dark.Subheader.PRIMARY : Typography.Light.Subheader.PRIMARY);
}

代码示例来源:origin: vaadin/material-theme-fw8

public void setHeaders(String... headers) {
  for (String header : headers) {
    Label lbl = new Label(header);
    lbl.setPrimaryStyleName(Typography.Dark.Table.Header.SECONDARY);
    this.headers.addComponent(lbl);
  }
}

代码示例来源:origin: vaadin/material-theme-fw8

public NavigationItem(Resource icon, String caption, Integer count) {
  String primaryStyleName = "md-naviitem";
  setPrimaryStyleName(primaryStyleName);
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.caption.setPrimaryStyleName(primaryStyleName + "-caption");
  this.count.setPrimaryStyleName(primaryStyleName + "-count");
  setIcon(icon);
  setCaption(caption);
  setCount(count);
  addComponents(this.icon, this.caption, this.count);
}

代码示例来源:origin: vaadin/material-theme-fw8

public TwoLineListItem(String primaryText, String secondaryText, boolean verticalPadding) {
  super(verticalPadding);
  addStyleName("two-line");
  setHeight(Metrics.List.TWO_LINE_HEIGHT, Unit.PIXELS);
  primary = new Label(primaryText);
  primary.setPrimaryStyleName(Typography.Dark.Subheader.PRIMARY);
  secondary = new Label(secondaryText);
  secondary.setPrimaryStyleName(Typography.Dark.Body1.SECONDARY);
  content.addComponents(primary, secondary);
  actionPrimary.addComponents(iconPrimary, content);
  actionSecondary.addComponent(iconSecondary);
  addComponents(actionPrimary, actionSecondary, divider);
}

代码示例来源:origin: vaadin/material-theme-fw8

public DatePickerHeader(InlineDateField field, boolean lightTheme) {
    setFlexDirection(FlexDirection.COLUMN);
    setJustifyContent(JustifyContent.CENTER);
    addStyleName(Paddings.Horizontal.LARGE);
    addStyleName(FlexItem.FlexShrink.SHRINK_0);

    this.field = field;
    field.addValueChangeListener((HasValue.ValueChangeListener<LocalDate>) event -> {
      year.setValue(field.getValue().format(DateTimeFormatter.ofPattern("yyyy")));
      date.setValue(field.getValue().format(DateTimeFormatter.ofPattern("EEE, MMM d")));
    });

    setHeight(Metrics.DatePicker.HEADER_HEIGHT, Unit.PIXELS);
    addStyleName(lightTheme ? MaterialColor.BLUE_500.getBackgroundColorStyle() : MaterialColor.GREY_700.getBackgroundColorStyle());

    year.setPrimaryStyleName(Typography.Light.Body2.SECONDARY);
    date.setPrimaryStyleName(Typography.Light.DatePicker.Title.PRIMARY);

    addComponents(year, date);
  }
}

代码示例来源:origin: peholmst/vaadin4spring

@Override
  public void createSection(CssLayout compositionRoot, SideBarSectionDescriptor descriptor, Collection<SideBarItemDescriptor> itemDescriptors) {
    Label header = new Label();
    header.setValue(descriptor.getCaption());
    header.setSizeUndefined();
    header.setPrimaryStyleName(ValoTheme.MENU_SUBTITLE);
    compositionRoot.addComponent(header);
    for (SideBarItemDescriptor item : itemDescriptors) {
      compositionRoot.addComponent(itemComponentFactory.createItemComponent(item));
    }
  }
}

代码示例来源:origin: vaadin/material-theme-fw8

public SingleLineListItem(String primaryText, boolean verticalPadding) {
  super(verticalPadding);
  addStyleName("single-line");
  setHeight(Metrics.List.SINGLE_LINE_HEIGHT, Unit.PIXELS);
  primary = new Label(primaryText);
  primary.setPrimaryStyleName(Typography.Dark.Subheader.PRIMARY);
  content.addComponent(primary);
  actionPrimary.addComponents(iconPrimary, content);
  actionSecondary.addComponent(iconSecondary);
  addComponents(actionPrimary, actionSecondary, divider);
}

代码示例来源:origin: vaadin/material-theme-fw8

public AppBar() {
  super();
  setPrimaryStyleName("md-appbar");
  addStyleName(MaterialColor.BLUE_500.getBackgroundColorStyle());
  naviIcon.setIcon(MaterialIcons.MENU);
  naviIcon.setPrimaryStyleName(Styles.Buttons.NAV_ICON);
  Label appBarTitle = new Label("Material Design");
  appBarTitle.setPrimaryStyleName(Typography.Light.Title.PRIMARY);
  appBarTitle.setSizeUndefined();
  addComponents(naviIcon, appBarTitle);
}

代码示例来源:origin: vaadin/material-theme-fw8

public void addItem(Object... values) {
  FlexLayout item = new FlexLayout();
  item.setPrimaryStyleName("md-datatable-row");
  item.addStyleName(Spacings.Right.LARGE);
  item.addStyleName(Paddings.Vertical.TABLE);
  for (Object value : values) {
    if (value instanceof String) {
      Label lbl = new Label((String) value);
      lbl.setPrimaryStyleName(Typography.Dark.Table.Row.PRIMARY);
      item.addComponent(lbl);
    } else if (value instanceof Component) {
      item.addComponent((Component) value);
    }
  }
  items.addComponent(item);
}

代码示例来源:origin: vaadin/material-theme-fw8

this.titleLabel.setPrimaryStyleName(Typography.Dark.Table.Title.PRIMARY);
this.titleLabel.setWidth(100, Unit.PERCENTAGE);
addComponent(this.titleLabel);
  if (size > 0) {
    titleLabel.setValue(size + (size == 1 ? " item selected" : " items selected"));
    titleLabel.setPrimaryStyleName(Typography.Dark.Subheader.PRIMARY);
    titleLabel.addStyleName(selectedFontColor.getFontColorStyle());
    addStyleName(selectedBackgroundColor.getBackgroundColorStyle());
  } else {
    titleLabel.setValue(this.title);
    titleLabel.setPrimaryStyleName(Typography.Dark.Table.Title.PRIMARY);
    titleLabel.removeStyleName(selectedFontColor.getFontColorStyle());
    removeStyleName(selectedBackgroundColor.getBackgroundColorStyle());

代码示例来源:origin: vaadin/material-theme-fw8

this.stepLabel.setPrimaryStyleName(Typography.Light.Caption.PRIMARY);
this.stepLabel.addStyleName(FLEXLAYOUT);
this.stepLabel.addStyleName(AlignItems.CENTER.getStyleName());
this.nameLabel.setPrimaryStyleName(Typography.Dark.Body1.PRIMARY);
this.infoLabel.setPrimaryStyleName(Typography.Dark.Caption.SECONDARY);

代码示例来源:origin: vaadin/material-theme-fw8

public MDTextFieldBox(String label, boolean light) {
  String primaryStyleName = light ? Styles.TextFieldBoxes.LIGHT : Styles.TextFieldBoxes.DARK;
  setPrimaryStyleName(primaryStyleName);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.ripple.setPrimaryStyleName(primaryStyleName + "-ripple");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, ripple, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDPasswordField(String label, boolean light) {
  String primaryStyleName = light ? Styles.TextFields.LIGHT : Styles.TextFields.DARK;
  setPrimaryStyleName(primaryStyleName);
  setFloatingLabelEnabled(true);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDTextAreaBox(String label, boolean light) {
  String primaryStyleName = light ? Styles.TextFieldBoxes.LIGHT : Styles.TextFieldBoxes.DARK;
  setPrimaryStyleName(primaryStyleName);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.ripple.setPrimaryStyleName(primaryStyleName + "-ripple");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, ripple, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDDateTimeField(String label, boolean light) {
  String primaryStyleName = light ? Styles.DateFields.LIGHT : Styles.DateFields.DARK;
  setPrimaryStyleName(primaryStyleName);
  setFloatingLabelEnabled(true);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDTextField(String label, boolean light) {
  String primaryStyleName = light ? Styles.TextFields.LIGHT : Styles.TextFields.DARK;
  setPrimaryStyleName(primaryStyleName);
  setFloatingLabelEnabled(true);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDDateField(String label, boolean light) {
  String primaryStyleName = light ? Styles.DateFields.LIGHT : Styles.DateFields.DARK;
  setPrimaryStyleName(primaryStyleName);
  setFloatingLabelEnabled(true);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addValueChangeListener(event -> updateFloatingLabelPosition(event.getValue()));
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, this.helper);
}

代码示例来源:origin: vaadin/material-theme-fw8

public MDComboBox(String label, boolean light) {
  String primaryStyleName = light ? Styles.ComboBoxes.LIGHT : Styles.ComboBoxes.DARK;
  setPrimaryStyleName(primaryStyleName);
  this.label.setValue(label);
  this.label.setPrimaryStyleName(primaryStyleName + "-label");
  this.label.addStyleName(RESTING);
  this.label.setWidthUndefined();
  this.icon.setPrimaryStyleName(primaryStyleName + "-icon");
  this.field.setPrimaryStyleName(primaryStyleName + "-input");
  this.field.addFocusListener(event -> {
    addStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addBlurListener(event -> {
    removeStyleName("focus");
    updateFloatingLabelPosition(this.field.getValue());
  });
  this.field.addValueChangeListener(event -> {
    if (generator != null) {
      Resource itemIcon = generator.apply(event.getValue());
      if (itemIcon instanceof MaterialIcons) setIcon((MaterialIcons) itemIcon);
      else setIcon(itemIcon);
    }
    updateFloatingLabelPosition(event.getValue());
  });
  this.helper.setPrimaryStyleName(primaryStyleName + "-helper");
  this.helper.setWidthUndefined();
  addComponents(this.label, icon, field, this.helper);
  setFloatingLabelEnabled(true);
}

代码示例来源:origin: vaadin/material-theme-fw8

public SimpleDialog(String title, String message, boolean lightTheme) {
  super(title);
  addStyleName(lightTheme ? Styles.Windows.LIGHT : Styles.Windows.DARK);
  label = new Label(message);
  label.setPrimaryStyleName(lightTheme ? Typography.Dark.Subheader.SECONDARY : Typography.Light.Subheader.SECONDARY);
  label.addStyleName(Paddings.Horizontal.LARGE + " " + Paddings.Bottom.LARGE);
  // Footer
  cancel = new Button("Cancel");
  cancel.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);
  cancel.addClickListener(e -> close());
  ok = new Button("OK");
  ok.setPrimaryStyleName(lightTheme ? Styles.Buttons.Flat.LIGHT : Styles.Buttons.Flat.DARK);
  ok.addClickListener(e -> close());
  footer = new FlexLayout(cancel, ok);
  footer.setJustifyContent(FlexLayout.JustifyContent.FLEX_END);
  footer.addStyleName(Paddings.All.SMALL + " " + Spacings.Right.SMALL + " " + FlexItem.FlexShrink.SHRINK_0);
  footer.setWidth(100, Unit.PERCENTAGE);
  // Content wrapper
  content = new FlexLayout(FlexLayout.FlexDirection.COLUMN, label, footer);
  setContent(content);
}

相关文章