Search code examples
java-melwuit

How to create HyperLink in LWUIT


I want to create a hyperlink using lwuit and i want to show it on myForm Screen?when i click on the link,it should navigate to the link,i have tried this for LCDUI,I got the result,but i dont know ,how to do it using LWUIT?


Solution

  • There is no specific control for hyperlink in lwuit. But, we can create hyperlink look using buttons.

    Button btnHyperlink = new Button("Hyperlink");
    btnHyperlink.getUnselectedStyle().setBorder(null);
    btnHyperlink.getSelectedStyle().setBorder(null);
    btnHyperlink.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM,Font.STYLE_UNDERLINED, Font.SIZE_MEDIUM));
    btnHyperlink.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM,Font.STYLE_UNDERLINED | Font.STYLE_BOLD, Font.SIZE_MEDIUM));
    btnHyperlink.getUnselectedStyle().setFgColor(0x0000ff);
    btnHyperlink.getSelectedStyle().setFgColor(0x0000ff);
    

    To navigate to another link when click the button, write the navigating code in button's action listener.