Is there any way to handle viwing form in protrate or landscape?
I want to check the abitlity to show my app in landscape if the device support, so, is there any way to do that?
in j2me there's no API to see if the app is in portrait or lanscape mode - the app just receives a signal that screen size changed. In LWUIT it will force re-layouting current form, and layout class can care about new screen size, if you implement your own Layout (standard ones are plain and do not need to handle such cases). Also you may change layout in form in Form.sizeChanged(), this is probably most suitable place for screen orientation handling code.
In Android, you can define different sets of layouts (they are present as XML files) for screen orientations (and different screen sizes). I do no think LWUIT has something like that yet.
We would like to avoid the Android approach where developers can create UI's for 12 different resolutions (densities x resolutions) which doubles again if you add landscape, their case is much simpler since they don't need to support as many resolutions than we do. That's going back to the j2me polish approach which ended up being a maintenance nightmare.
We do however adress the various use cases of layout change in rotation e.g. the Musix application shifts the cover art image which is on top of the song details in portrait to the side when in landscape. This is achieved via a special API in border layout called: defineLandscapeSwap (this is customizable in the GUI builder too).
It allows moving information around in landscape, GridLayout also has a similar feature where it can adapt to available space called setAutoFit(true) which will effectively recalculate the columns/rows based on the data and available space. We intend to offer additional features like that such as master-detail view etc. which will allow us to ease tablet and TV application development.
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.