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
Trusted Contributor
Posts: 115
Registered: ‎03-24-2011
My Device: 8310 curve
My Carrier: PLAY

Change private static String.

I have two class.

 

First is Screen1.java and twice Screen2.java

 

I need change string in Screen2.

 

public class Screen2 {

    private static  String brok = "deviceside=true";
   
   private static Connection connect(String host, int port) throws IOException{
        
      Connection conn = Connector.open("socket://"+host+":"+port+brok);
        
          return conn;
    }

}

And this is screen1:

class  Screen1  extends MainScreen implements FieldChangeListener{
Screen1{
//some code
}

public void fieldChanged(Field field, int context) {

if (field == APNButton) { 
        
     //I need change String brok when press button...but i dont know how to.
        
    }
}

}	

 Any simple sample for this code??? THX

 
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Change private static String.

write a public method.

just to be on the safe side i also mention: if you execute blocking operations, like networking, use a separate thread.
see
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Trusted Contributor
Posts: 115
Registered: ‎03-24-2011
My Device: 8310 curve
My Carrier: PLAY

Re: Change private static String.

No, i need a sample...i dont understend anything yet!

 

Anyway...anybody help me? (not simon).

 
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change private static String.

[ Edited ]

Can I presume that you are new to Java?

 

The approach you are taking here is not standard in Java.  If you have data that is shared between two screens, then I suspect it would be more usual to create an Object that is shared between the two screens, and provide both Screens with references to this Object.

 

You can easily provide both Screens with references by passing the reference in the Screen's constructor.

 

Hope this makes sense.

 

If it doesn't, then can I recommend that you get a good book on Java?

Trusted Contributor
Posts: 115
Registered: ‎03-24-2011
My Device: 8310 curve
My Carrier: PLAY

Re: Change private static String.

OMFG!!! Level6 and cant help me with simple problem....

 

The answer I got on another forum, and a professional answer!

 

Use this forum to get the answer is almost impossible.

 
 
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Change private static String.

don't hesitate to share the answer here and mark the thread as solved, then.
I hope you find somebody who fits your needs better than us two the next time!
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Trusted Contributor
Posts: 115
Registered: ‎03-24-2011
My Device: 8310 curve
My Carrier: PLAY

Re: Change private static String.

I give up with the help of this forum, your merit.