Here is an implemantation of a LINK component for the LWUIT enviroment under J2ME (Java ME).
This code creates a lwuit link component based on the lwuit button which not have a border and is transparent! also have an appropriate color (blue) and font style (underline).
hope it is helpful:
code example:
Button btn = new Button("LINK1");
//btn.getStyle().setBorder(Border.createEmpty());
btn.getUnselectedStyle().setBorder(Border.createEmpty());
btn.getSelectedStyle().setBorder(Border.createEmpty());
//btn.getStyle().setBgTransparency(100);
btn.getUnselectedStyle().setBgTransparency(100);
btn.getSelectedStyle().setBgTransparency(100);
//btn.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
btn.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
btn.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED | Font.STYLE_BOLD, Font.SIZE_MEDIUM));
//btn.getStyle().setFgColor(0x0000ff);
btn.getUnselectedStyle().setFgColor(0x0000ff);
btn.getSelectedStyle().setFgColor(0x0000ff);
Enjoy!
This code creates a lwuit link component based on the lwuit button which not have a border and is transparent! also have an appropriate color (blue) and font style (underline).
hope it is helpful:
code example:
Button btn = new Button("LINK1");
//btn.getStyle().setBorder(Border.createEmpty());
btn.getUnselectedStyle().setBorder(Border.createEmpty());
btn.getSelectedStyle().setBorder(Border.createEmpty());
//btn.getStyle().setBgTransparency(100);
btn.getUnselectedStyle().setBgTransparency(100);
btn.getSelectedStyle().setBgTransparency(100);
//btn.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
btn.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
btn.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED | Font.STYLE_BOLD, Font.SIZE_MEDIUM));
//btn.getStyle().setFgColor(0x0000ff);
btn.getUnselectedStyle().setFgColor(0x0000ff);
btn.getSelectedStyle().setFgColor(0x0000ff);
Enjoy!
You can upgrade your code and create an object (class) looking like:
ReplyDeletepublic class LinkButton extends Button
{
public LinkButton()
{
this.getUnselectedStyle().setBorder(Border.createEmpty());
this.getSelectedStyle().setBorder(Border.createEmpty());
this.getUnselectedStyle().setBgTransparency(100);
this.getSelectedStyle().setBgTransparency(100);
this.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
this.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED | Font.STYLE_BOLD, Font.SIZE_MEDIUM));
this.getUnselectedStyle().setFgColor(0x0000ff);
this.getSelectedStyle().setFgColor(0x0000ff);
}
}
i noticed that you also need to handle the PRESSED style by: this.getPressedStyle() for handling color/font/border and additionally set the padding & marging to (0,0,0,0)
j.l
here is my style code:
ReplyDelete// border
btn.getStyle().setBorder(Border.createEmpty());
btn.getUnselectedStyle().setBorder(Border.createEmpty());
btn.getSelectedStyle().setBorder(Border.createEmpty());
// transparent
btn.getStyle().setBgTransparency(100);
btn.getUnselectedStyle().setBgTransparency(100);
btn.getSelectedStyle().setBgTransparency(100);
// margin & padding
btn.getStyle().setMargin(0, 0, 0, 0);
btn.getSelectedStyle().setMargin(0, 0, 0, 0);
btn.getUnselectedStyle().setMargin(0, 0, 0, 0);
btn.getPressedStyle().setMargin(0, 0, 0, 0);
btn.getStyle().setPadding(0, 0, 0, 0);
btn.getSelectedStyle().setPadding(0, 0, 0, 0);
btn.getUnselectedStyle().setPadding(0, 0, 0, 0);
btn.getPressedStyle().setPadding(0, 0, 0, 0);
j.l
hi, i want to give an action for the button could you please help
ReplyDeleteThanks for sharing this huge info with us.
ReplyDelete