use of com.codename1.rad.attributes.MaterialIcon in project CodenameOne by codenameone.
the class ComponentSelector method setIcon.
/**
* Sets the icon of all elements in this set to a material icon. This will use
* the foreground color of each label as the icon's foreground color.
* @param materialIcon The icon charcode.
* @param size The size of the icon (in mm)
* @return Self for chaining
* @see FontImage#createMaterial(char, com.codename1.ui.plaf.Style, float)
*/
public ComponentSelector setIcon(char materialIcon, float size) {
for (Component c : this) {
if (c instanceof Label) {
Label l = (Label) c;
Style style = new Style();
Style cStyle = c.getUnselectedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
l.setIcon(FontImage.createMaterial(materialIcon, style, size));
if (c instanceof Button) {
Button b = (Button) c;
style = new Style();
cStyle = c.getPressedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
b.setPressedIcon(FontImage.createMaterial(materialIcon, style, size));
}
}
}
return this;
}
use of com.codename1.rad.attributes.MaterialIcon in project CodenameOne by codenameone.
the class Tabs method addTab.
/**
* Adds a <code>component</code>
* represented by a <code>title</code> and/or <code>icon</code>,
* either of which can be <code>null</code>.
* Cover method for <code>insertTab</code>.
*
* @param title the title to be displayed in this tab
* @param materialIcon one of the material design icon constants from {@link com.codename1.ui.FontImage}
* @param iconSize icon size in millimeters
* @param component the component to be displayed when this tab is clicked
* @return this so these calls can be chained
*
* @see #insertTab
* @see #removeTabAt
*/
public Tabs addTab(String title, char materialIcon, float iconSize, Component component) {
int index = tabsContainer.getComponentCount();
FontImage i = FontImage.createMaterial(materialIcon, "Tab", iconSize);
insertTab(title, i, component, index);
Style sel = getUIManager().getComponentSelectedStyle("Tab");
i = FontImage.createMaterial(materialIcon, sel, iconSize);
setTabSelectedIcon(index, i);
return this;
}
use of com.codename1.rad.attributes.MaterialIcon in project CodenameOne by codenameone.
the class ComponentSelector method setIcon.
/**
* Sets the icon of all elements in this set to a material icon. This will use
* the foreground color of the label.
* @param materialIcon The material icon charcode.
* @return Self for chaining.
*/
public ComponentSelector setIcon(char materialIcon) {
for (Component c : this) {
if (c instanceof Label) {
Label l = (Label) c;
Style style = new Style();
Style cStyle = c.getUnselectedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
l.setIcon(FontImage.createMaterial(materialIcon, style, 3));
if (c instanceof Button) {
Button b = (Button) c;
style = new Style();
cStyle = c.getPressedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
b.setPressedIcon(FontImage.createMaterial(materialIcon, style, 3));
}
}
}
return this;
}
Aggregations