Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

To display the labelfields using thread

i want to display 5 labelfields one after other within time interval using threads.I got labelfields all in once.I want to display one after other with timeframe of 1 sec.

 final class example extends UiApplication
 {
    
     public static void main (String[] args)
     {   example theApp = new example();
         theApp.enterEventDispatcher();
     }
     example()
     {
         pushScreen(new exampleScreen());
     }
 
 }
 final class exampleScreen extends MainScreen
 
 {
     LabelField ss[]=new LabelField[5];
     exampleScreen (boolean b)
      {
            
        UiApplication.getUiApplication().invokeLater(new Runnable()
       {
           public void run()
           {
              
                for(int i=0;i<5;i++)
                        {
                                ss[i]=new LabelField("ds"+i);
                                add(ss[i]);
                                try {
                                Thread.sleep(1000);
                                } catch (InterruptedException ex) {
                                    ex.printStackTrace();
                                }                             
                         }   
             }
          
       });
      }
    
   public boolean onClose()
   {
     return true;       
    
   } 
 }

Guys ,help me to sort the problem 

Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: To display the labelfields using thread

Why can't you update only the text value based on the timing?

Do you have any specific need for doing this?

Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: To display the labelfields using thread

thanks for quick reply,

 

i do not know how the thread is working in blackberry ....

 

In my code i want the labelfield to be created for every second ......I choose this pgm to understand the thread concept. otherwise help me to know the concept in BBerry.

                                                                         Thanks.

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: To display the labelfields using thread

Check this thred. Very useful for beginners.

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=13264


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: To display the labelfields using thread

i have gone through it ,and did the program,but i dont understand what sort of problem i made in my program,
Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: To display the labelfields using thread

"i do not know how the thread is working in blackberry ...."

 

Its working the same way as it works in any J2ME or J2SE applications. 

 

"In my code i want the labelfield to be created for every second ......I choose this pgm to understand the thread concept. otherwise help me to know the concept in BBerry."

 

Good to know. Just start from the basic one by one. So, you won't be cluttered with more problems at once. 

 

Refer here for documentation about thread :

http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html

 

 And also refer the link provided by BBDeveloper. You need to refer all those relevant links in that post to gather more knowledge!


Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

Re: To display the labelfields using thread

hello sir,i am getting the output with labelfields displayed all in single ui Screen,i want to  display them on screen once  the labellfield is created,how should to display on screen,whats problem with my code sir,

 

thanks