TextField isVisible() function in LWUIT dosent work as aspected

116 Views Asked by At

I am working on an application for mobile using LWUIT library. Its a form with containers and components. I am having a container c2 which contains certain controls like various textFields, label etc. I am trying to put validations on it. But in certain cases the validation should only work on the components which are visible on the screen. For example i have a situation where the c2 container is not on the screen and then i try to check if it is visible or not by the following code:

System.out.println(txt_Name.isVisible());

Inspite of being not visible on the screen it still shows as TRUE. But i guess it should show FALSE. I tried isEnabled but it is not as per my requirement. I ran out of ideas and the last resort was SO. Any help would be appreciated.

1

There are 1 best solutions below

5
On

I think that the method isVisible() always return a boolean value od the state of the Component. I mean, if the Component is showing in the interface, it will return true, but it's not necesary to be showing the Componentin the screen.

If you want to check if your Component is on the screen or not, I will recommend you to check the coordinates of your Componentusing getX() and getY()and checking if it is inisde the screen or not. Try and tell us what you have got.