Form hi = new Form("Badge");
Button chat = new Button("");
FontImage.setMaterialIcon(chat, FontImage.MATERIAL_CHAT, 7);
Label badge = new Label("33");
badge.getAllStyles().setBorder(RoundBorder.create().rectangle(true));
badge.getAllStyles().setAlignment(Component.CENTER);
int size = Display.getInstance().convertToPixels(1.5f);
badge.getAllStyles().setFont(Font.createTrueTypeFont("native:MainLight", "native:MainLight").derive(size, Font.STYLE_PLAIN));
Container cnt = LayeredLayout.encloseIn(chat, FlowLayout.encloseRight(badge));
cnt.setLeadComponent(chat);
hi.add(cnt);
TextField changeBadgeValue = new TextField("33");
changeBadgeValue.addDataChangedListener((i, ii) -> {
badge.setText(changeBadgeValue.getText());
cnt.revalidate();
});
Font materialFont = FontImage.getMaterialDesignFont();
int h = changeBadgeValue.getPreferredH() / 2;
FontImage tick = FontImage.createFixed("" + FontImage.MATERIAL_CHECK, materialFont, 0x00ff00, h, h);
FontImage cross = FontImage.createFixed("" + FontImage.MATERIAL_CLOSE, materialFont, 0xff0000, h, h);
Label verify = new Label();
verify.getAllStyles().setAlignment(Component.CENTER);
verify.setIcon(cross);
Container cnt1 = LayeredLayout.encloseIn(changeBadgeValue, FlowLayout.encloseRight(verify));
cnt1.setLeadComponent(changeBadgeValue);
hi.add(cnt1);
hi.show();