Mr. Hat Mr. Hat - 5 months ago 36
Java Question

How do I access UI components in a .res file with Codename One?

I'm new to Codename one, and I'm trying to build a simple application where when you press a button, a label changes its text. I decided to utilize the UI builder CodenameOne provides because it is simple and easy to use, much less hassle than coding a UI by hand. I created a button and a label. I pressed the 'Action Event' button to create a listener method for the button. I went to the listener method to put in my code that changes the label. But the problem is that I don't know how to access the label in the .res file to edit the text. So my question is, How do I change the stuff in the .res file from my code? I searched the Codename One site, but I couldn't find anything. I looked at this question, but it didn't seem to address my problem.

I feel like the answer is probably right under my nose, so I apologize if this is a noob question, but I've been looking for an answer for a few days now.


Take a look at this video, helped me a lot regarding this.

Anyway a small example, assuming you have a Button named "Button1" in your UI. You can access it in your StateMachine under findButton1()