0

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.

Nitesh Verma
  • 1,795
  • 4
  • 27
  • 46

1 Answers1

1

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.

Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • the first time i got (0,0) and when the component was added the result was (2, 27). But when i again disabled it as pet the condition i still got (2, 27). Could there be anything related to the container in which the component is contained? – Nitesh Verma Oct 23 '13 at 09:09
  • getX() and getY() will give you the coordinates of the element...I think that this is not what you wanna – Mun0n Oct 23 '13 at 09:37
  • if you use...isFocused(), you will now if the element have the focus of the app...and if it has it...is showing. In what platform are you building this app? Nokia SDK 2? SDK 1.1? – Mun0n Oct 23 '13 at 09:38
  • SDK 1.1 is the platform – Nitesh Verma Oct 23 '13 at 11:14
  • 1
    The `isVisible()` method is the getter for the `setVisible(boolean)` method. It allows you to toggle visibility state so the component won't be rendered. It isn't designed to let you know if a compoennt is rendered on the screen. Trying to check if a container is on the screen is probably not the right way to do it, I suggest backtracking to why you are trying to do this and what you are tying to accomplish then rephrasing the question with that information in mind. – Shai Almog Oct 28 '13 at 19:07