Skip to main content

How to handle landscape and portrait?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
3 replies [Last post]
abuhmead1987
Offline
Joined: 2010-04-21

Dear Guys,

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?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mixaz
Offline
Joined: 2009-09-04

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.

Mike

vprise
Offline
Joined: 2003-11-07

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.

abuhmead1987
Offline
Joined: 2010-04-21

Thanks