×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Lwuit HTMLComponent problem

    Hi
    I'm developing using lwuit 1.5
    1) In my app I use HTMLComponent
    When I run my app on nokia 5800 express music in the portrait mode & in the landscape mode it display all the content just fine but the problem is that when I re-rotate the mobile to the portrait mode it remove some words from the content though it display all of it in the beginning.

    2) Then I thought to load a local html file but I don't know how, so could anyone help me with this

    3) or if I use a textarea instead is there a way to display more than one font in the textarea and to display some words in bold and other in plain
    & Thanks in advance

  2. #2
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    Have you taken a look at the HTMLComponent section in the LWUIT developer library?

    There is an example of a DocumentRequestHandler implementation that should help you displaying local files.

    You could also pass your html text directly to the component. Something like this:

    HTMLComponent htmlC = new HTMLComponent(null);
    htmlC.setBodyText("Hello <b>bold text</b>");
    -CarlosDL

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    As for displaying different fonts in the same TextArea, no, that is not possible.
    -CarlosDL

  4. #4
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Lwuit HTMLComponent problem

    For displaying a html page I used this code:
    HTMLComponent htmlc = new HTMLComponent();

    DocumentInfo docInfo = htmlc.getDocumentInfo() ;

    DocumentRequestHandler handler =htmlc.getRequestHandler();

    htmlc.setRTL(true);

    htmlc.setPage("jar:///a.html");

    a is the name of the html file that I want it to be loaded and it reside in the src folder
    but when I run it there is nothing to display
    so is there any thing wrong in the code
    & thanks for the reply

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Lwuit HTMLComponent problem

    A thing you may want to consider is checking if a.html is really in the .jar file, and exactly where.

  6. #6
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    Try using a FileRequestHandler like the one shown here: LWUIT Developer's Library: Implementing a simple DocumentRequestHandler and change your code to something like this:

    Code:
    		FileRequestHandler handler = new FileRequestHandler();
    		HTMLComponent htmlc = new HTMLComponent(handler);
    		htmlc.setRTL(true);
    
    		form.addComponent(htmlc);
    		htmlc.setPage("file://a.html");
    -CarlosDL

  7. #7
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Lwuit HTMLComponent problem

    I used the DocumentRequestHandler as you said & I change the code but nothing appear
    (the a.html file is in the src folder is that the right place)
    & Thanks so much for replying

  8. #8
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    Quote Originally Posted by Youssef77 View Post
    I used the DocumentRequestHandler as you said & I change the code but nothing appear
    (the a.html file is in the src folder is that the right place)
    & Thanks so much for replying
    It all depends on where the file is located inside the jar file (as wizard_hu_ suggested). If the file is at the jar root, then "file://a.html" should work. That would usually be the path if you put it inside the src or res folders.

    If you are testing it on the emulator, go to "...<path to your project>\.mtj.tmp\emulation\ and open the jar file (you can use winrar, or any similar program to do it) and see where the file is located, then use the appropriate path in your code.
    -CarlosDL

  9. #9
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    I would also suggest trying with a very simple HTML file, to make sure the problem is not related to the file contents.

    Something like this should be enough to test:

    HTML Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <h1>My First Heading</h1>
    
    <p>My first paragraph.</p>
    
    </body>
    </html>
    -CarlosDL

  10. #10
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Lwuit HTMLComponent problem

    I entered the .mtj.tmp folder as you told me then the emulation folder then I change the jar extension to zip
    inside the zip folder there is 2 folder (the com folder & the meta inf folder & the a.html file)
    but thought that it doesn't appear at all & when I run it in the emulator it says " error connecting to stream"
    so what I should do??

  11. #11
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    How about this?

    Code:
    htmlc.setPage("file:///a.html");
    -CarlosDL

  12. #12
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Lwuit HTMLComponent problem

    Yes it work fine
    Thank you very much

  13. #13
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    Re: Lwuit HTMLComponent problem

    It work fine but there is another problem related to the same issue:
    the html code you give me work fine
    but when I wrote a html code with Arabic characters so I save it as utf-8 or Unicode nothing appear in the emulator though the html work fine in the internet browser
    so what is the solution for that issue
    & thanks a lot

  14. #14
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: Lwuit HTMLComponent problem

    Have you tried this?

    Code:
    		htmlc.setPage("file:///a.html");
    		htmlc.getDocumentInfo().setEncoding("UTF-8");
    -CarlosDL

Similar Threads

  1. Replies: 2
    Last Post: 2012-11-23, 07:39
  2. LWUIT HtmlComponent NoSuchElementException
    By pavanragi in forum Mobile Java General
    Replies: 0
    Last Post: 2012-10-16, 08:35
  3. LWUIT HtmlComponent out of memory exception
    By pavanragi in forum Mobile Java General
    Replies: 6
    Last Post: 2012-10-11, 12:07
  4. How to append LWUIT List screen to a LWUIT Form in j2me?
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-08-06, 07:01
  5. Replies: 0
    Last Post: 2011-08-25, 05:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •