The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: how to go to next lines in a label

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 21 - Last Post: Sep 7, 2009 5:48 AM by: raki_j2me Threads: [ Previous | Next ]
elaltaico

Posts: 84
how to go to next lines in a label
Posted: Jun 24, 2009 6:46 AM
 
  Click to reply to this thread Reply

Hello


I am using J2ME LWUIT to design my application. I take data from web server and display it on screen. I can do it without any problem. Unfortunately when the text is so long, I want Label to go to next line. But it writes all the text at same line.Then the user needs to wait the line to stop to read whole Label. Could you please tell me a way for user to go to next line when the text is long enough ? Thank you in advance.


Regards
Altayli

Here is how I defined my Label:
label9.setText(topkapi.TopkapiAyrinti);
label9.setFocusable(true);
b2.addComponent(label9);

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 12:12 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

Hi,

Try this

TextArea textArea= new TextArea("Hello World, This is my first LWUIT Application, Enjoy");

textArea.setSingleLineTextArea(false);

Regards,
Ashish
www.umundoinc.com

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 12:41 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

Hello ashish

There is no textArea2.setSingleLineTextArea(false); definition on LWUIT. It tells me "cannot find symbol".. when I use setSingleTextArea().

Regards
Altayli

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 12:49 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

or the problem comes from I am using older version of LWUIT? I even implemented import com.sun.lwuit.TextArea;. But it does not recognize setSingleLineTextArea(false

menion

Posts: 16
Re: how to go to next lines in a label
Posted: Jun 25, 2009 4:20 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

I think that this feature is newer that version you can directly download. Use actual version from SVN.

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 4:50 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

Sorry to mention about Source.

Please download the latest svn version.

It will solve your problem. because it has solved my problem..

Regards,
Ashish

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 5:23 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

Hi

eee I tried everywhere.Could you please provide me a link which has latest svn version of LWUIT. I am pulling my hairs right here. Thank you so much and apologizes for disturbing.


Regards
Altayli

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 5:33 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

https://lwuit.dev.java.net/svn/lwuit/trunk

you can get source code from here.

Regards,
Ashish
www.umundoinc.com

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 6:02 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

Hello


I thought I would download a new LWUIT jar. I found TextArea.src from the link that you provide me and I added it on my classfolder. And I found out public boolean isSingleLineTextArea() { return singleLineTextArea; this function. So sorry it will be really a simple question do I need to add TextArea somewhere or do I need to change TextArea.src with some file? Thank you so much and apologizes for disturbing. I am beginner on J2ME.

Regards
Altayli

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 11:28 PM   in response to: elaltaico
 
  Click to reply to this thread Reply

Hello


I could not find the .jar under dist directory at https://lwuit.dev.java.net/svn/lwuit/trunk. Could you please help me how to setup it? I need to add TextArea.java to my project folder ? Thank you so much and apologizes for disturbing again

Regards
Altayli

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 11:40 PM   in response to: elaltaico
 
  Click to reply to this thread Reply

you have to copy src folder to your source from SVN.

you do not need jar file just copy folder to your source directory.

Regards
Ashish
www.umundoinc.com
www.umundo.com

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 25, 2009 11:45 PM   in response to: elaltaico
 
  Click to reply to this thread Reply

ee . This time I can see the textArea1.setSingleLineTextArea(false); when i clicked "." before textArea1 but unfortunately I get following error :

C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\src\Midlet.java:150: cannot find symbol
symbol : method setSingleLineTextArea(boolean)
location: class com.sun.lwuit.TextArea
textArea1.setSingleLineTextArea(false);
1 error
C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\nbproject\build-impl.xml:405: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 11:52 PM   in response to: elaltaico
 
  Click to reply to this thread Reply

First Remove LWUIT Library from your netbeans project than

copy folder
https://lwuit.dev.java.net/svn/lwuit/trunk/MIDP/LWUIT/src/com

to

C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\src

now build and run it will work.

Regards,
Ashish
www.umundoinc.com
www.umundo.com

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 25, 2009 11:39 PM   in response to: elaltaico
Correct
  Click to reply to this thread Reply

you can use following link to solve your problem.

http://forums.java.net/jive/message.jspa?messageID=350857#350857

It has using of TextArea.
how to use in Container.



Regards,
Ashish

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 26, 2009 12:00 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

Hello Ashish

You used TextArea description= new TextArea("Hello World. Hello World. Hello World.,3,10) at your example. It means you gave the lines of the code before. My application reads the strings from php file and writes it to screen. As a result of that,the lines can be 100 or 50 . That's why I need a LWUIT system which adds lines automatically if the string is large. I can do it by using textArea.setSingleLineTextArea(false); ? and if I can could you please tell me how to add source to the lwuit application to use setSingleLineTextArea(false) ? I think I made a small mistake about downloading latest SVN of LWUIT. I would be so glad if you can tell me the process of https://lwuit.dev.java.net/svn/lwuit/trunk to my computer.

Apologizes for disturbing again but I have to fix it asap.

Regards
Altayli

elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 26, 2009 1:50 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

Hello

Thank you ashish. I fixed it by calculating character number then converting it to integer and dividing it by 10. As a result of that I can find out how many lines I will have. This is how I did

TextArea description= new TextArea("Hello World. Hello World. Hello World. sdfsdffffffsdfsddffffgkdljgkldfjgdklgjdlkgjdlkgjdklfgjdfklgjdklgfkldgkldfgjlkdjgdlkgjldkjgdklfgjdlkfgjdlfkgjdfklgjdlkgjdlkgjdfklgjlfsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfdsfsdfsdfsdf");
String schehrazad=description.toString();
int length=schehrazad.length();
int lengthh=(length/10)+1;
description= new TextArea("Hello World. Hello World. Hello World. sdfsdffffffsdfsddffffgkdljgkldfjgdklgjdlkgjdlkgjdklfgjdfklgjdklgfkldgkldfgjlkdjgdlkgjldkjgdklfgjdlkfgjdlfkgjdfklgjdlkgjdlkgjdfklgjlfsdfsdfsdfsdfsdfsdfsdfsdfsdfdsfdsfsdfsdfsdf",lengthh,10);
description.getStyle().setBgTransparency(0);
description.setGrowByContent(true);
description.setEditable(false);
description.setFocusable(false);

Regards
Altayli

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 26, 2009 1:56 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

I think this is not the right way to do it

please refere following code

import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.FocusListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Border;
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
/**
 *
 * @author Ashish
 */
public class Channel extends Container implements FocusListener
{
    Label pic = new Label("Pic");
 
    Label title= new Label("Title");
 
    Label url = new Label("Url");
 
    TextArea description= new TextArea("Hello World. Hello World. Hello World.");
 
 
    public Channel ()
    {
        setLayout(new BorderLayout());
        addComponent(BorderLayout.WEST, pic);
 
        Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
 
        title.getStyle().setBgTransparency(0);
        url.getStyle().setBgTransparency(0);
        description.getStyle().setBgTransparency(0);
        description.setSingleLineTextArea(false);
        description.setGrowByContent(true);
        
 
        cnt.addComponent(title);
        cnt.addComponent(url);
 
        addComponent(BorderLayout.CENTER, cnt);
 
        description.getStyle().setBorder(Border.createEmpty(), false);
        description.setGrowByContent(true);
        description.setEditable(false);
        description.setFocusable(false);
 
 
        addComponent(BorderLayout.SOUTH,description);
 
        getStyle().setBgTransparency(255);
        getStyle().setBgSelectionColor(0x00ff00);
        
        //getStyle().setFgSelectionColor(0x00ff00);
 
        setFocusPainted(true);
        setFocusable(true);
    }
 
    public void focusGained(Component arg0)
    {
       System.out.println(">>"+arg0);
    }
 
    public void focusLost(Component arg0)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }
 
    public void setDescription(String description)
    {
        this.description.setText(description);
    }
 
 
 
    }
 
 


elaltaico

Posts: 84
Re: how to go to next lines in a label
Posted: Jun 26, 2009 2:49 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

I would like to use description.setSingleLineTextArea(false); But, the problem is setSingleLineTextArea() does not work. I receive some errors when I use this command such as : C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\src\Midlet.java:192: cannot find symbol
symbol : method setSingleLineTextArea(boolean)
location: class com.sun.lwuit.TextArea
description.setSingleLineTextArea(false);
1 error
C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\nbproject\build-impl.xml:405: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 3 seconds)



I would like to use setSingleLineTextArea(boolean) if I cold use it.

Regards
Altayli

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Jun 26, 2009 2:58 AM   in response to: elaltaico
 
  Click to reply to this thread Reply

That means you did not copy the latest source code to you project please do the following thing.



First Remove LWUIT Library from your netbeans project than

copy folder
https://lwuit.dev.java.net/svn/lwuit/trunk/MIDP/LWUIT/src/com

to

C:\Users\GE BiliÅŸim\Documents\NetBeansProjects\MobileApplication59\src

now build and run it will work.

Regards,
Ashish
www.umundoinc.com
www.umundo.com

raki_j2me

Posts: 8
Re: how to go to next lines in a label
Posted: Sep 6, 2009 3:35 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

I went through the entire TextArea thread & just wanted to know the procedure to download the src file - because i am not able to download it at all. When i do right click - right click isn't working at all. So if u could just attach the src, it would be very helpful. Thanks in advance.

Rakesh

Message was edited by: raki_j2me

ashish_onmobile

Posts: 102
Re: how to go to next lines in a label
Posted: Sep 7, 2009 5:26 AM   in response to: raki_j2me
 
  Click to reply to this thread Reply

Hi Raki_j2me,

You should have installed SVN client in you pc. Please download to Tortoise svn from following site.

http://tortoisesvn.tigris.org/

After installation. create a new folder , right click on that folder - > select svn checkout-> copy and paste the give link to URL of repository : -> Select OK -> It will ask you the username and password Please enter your lwuit's forum password.

Regards,
Ashish

raki_j2me

Posts: 8
Re: how to go to next lines in a label
Posted: Sep 7, 2009 5:48 AM   in response to: ashish_onmobile
 
  Click to reply to this thread Reply

Hey..........Thanks a lot .....That reply was fast........and it worked like a charm....................Could u plz tell me how to limit number of characters in a TextField. I tried TextField.setMaxSize(10) & TextField.setDefaultMaxSize(10), but it is not limiting the textfield to 10 Characters. Thanks in advance.




 XML java.net RSS