View Single Post
  #2 (permalink)  
Old 07-23-2007, 12:11 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: Auto Resize Applications in J2ME ?

When you have programmed your midlet for perfect fitting of your test device screen resolution, for instance 176x208, and now you want to make the application adapt automatically for other screen sizes, you can do that with out making much of a change in the Midlet.

First of all you need to declare two public variables accessible through out the midlet. At the load of the midlet, get the getWidth and getHeight values of Display object.

scrnW=getWidth();
scrnH=getHeight();
hfactor=scrnW/176f;
vfactor=scrnH/208f;

Now multiply these factors with each hard coded values you have set for vertical and horizontal components of your drawing code. Make sure that you add the “f” after your constants for floating point accuracy
Reply With Quote