×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    Apr 2008
    Location
    Bangalore (INDIA)
    Posts
    25

    How to know device screen size without using canvas.

    Hi all,
    We developed an application where we need to calculate the device full screen size,
    in start application before initializing the canvas object.

    Is there any way to do this???


    thanks,
    mutturaj

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to know device screen size without using canvas.

    Quote Originally Posted by mutturajb View Post
    Hi all,
    We developed an application where we need to calculate the device full screen size,
    in start application before initializing the canvas object.

    Is there any way to do this???


    thanks,
    mutturaj
    You can write the lines as below-
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    /*
    * Canvas1.java
    *
    * Created on January 9, 2009, 6:16 PM
    *
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    */

    /**
    *
    * @author rajiv
    */
    public class Canvas1 extends Canvas
    {

    /** Creates a new instance of Canvas1 */
    public Canvas1()
    {
    setFullScreenMode(true);
    }

    protected void paint(Graphics graphics)
    {
    graphics.setColor(0);
    graphics.fillRect(0,0,getWidth(),getHeight());
    graphics.setColor(255,255,255);
    graphics.drawString("w = "+getWidth(),10,20,0);
    graphics.drawString("h = "+getHeight(),10,40,0);
    }
    }
    just test the code..
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Apr 2008
    Location
    Bangalore (INDIA)
    Posts
    25

    Re: How to know device screen size without using canvas.

    Hi Raj,

    Please read my question again,
    I asked without using canvas.

    Thanks,
    mutturaj

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to know device screen size without using canvas.

    In MIDP-2.0, all subclasses of Displayable have getHeight(), getWidth() and sizeChanged(). You don't need specifically to use a Canvas. However, which screen size do you need? Regular? FullScreen? Lanscape or portrait?

    Why do you need the screen size before creating a Canvas?

    Cheers,
    Graham.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Location
    Bangalore (INDIA)
    Posts
    25

    Re: How to know device screen size without using canvas.

    Hi Graham,
    We need it so that we can send as a parameter to the servlet request.



    Thanks,
    mutturaj

  6. #6
    Registered User
    Join Date
    Apr 2008
    Location
    Bangalore (INDIA)
    Posts
    25

    Re: How to know device screen size without using canvas.

    Hi Graham,
    We need it so that we can send as a parameter to the servlet request.
    We need device full screen size.


    Thanks,
    mutturaj

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to know device screen size without using canvas.

    But why do you need this before displaying a Canvas? What will be on the screen during the servlet request?

  8. #8
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: How to know device screen size without using canvas.

    Hi,
    Quote Originally Posted by mutturajb View Post
    Hi Graham,
    We need it so that we can send as a parameter to the servlet request.
    We need device full screen size.


    Thanks,
    mutturaj
    what if u send the request after creating a canvas object? There is nothing to show that effects ur UI. May be u r requesting to server for some images according to screen size but still no matters if u request after creating the canvas object. Just dont set it current displayable. create object -> request to server -> then do what u want to do..
    thanks,
    jitu_goldie..

    KEEP TRYING..

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to know device screen size without using canvas.

    Hi,
    ANd when you must be working with the actual screen size,what you will do of screen size
    Width = 240
    height = 318;

    with of the screen size device 240x320..
    now what you will do with the incorrect values?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Thumbs down Re: How to know device screen size without using canvas.

    creating canvas object before calling a CGI is no problem.
    just use the simple code as follows

    Code:
    public class MyClass
    {	int w=0,h=0;
    	public void someMethod()
    	{	TestCanvas t=new TestCanvas();
    		//	Simply creating the TestCanvas object will call paint() method		//	which will put values in w,h
    		//	Now call your servlet/CGI as follows
    		String url="http://www.mywbsite.com?w="+w+"&h="+h;
    	}
    	class TestCanvas extends Canvas
    	{	public void paint(Graphics g)
    		{	w=getWidth();
    			h=getheight();
    		}
    	}
    }
    i don't think it is any problem..
    Vineet Billorey "The Great"

  11. #11
    Registered User
    Join Date
    Apr 2008
    Location
    Bangalore (INDIA)
    Posts
    25

    Re: How to know device screen size without using canvas.

    Hi all,

    Thanks for the quick reply,
    my problem solved....

    regards,
    mutturaj

  12. #12
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to know device screen size without using canvas.

    Quote Originally Posted by vineetbillorey View Post
    creating canvas object before calling a CGI is no problem.
    just use the simple code as follows

    Code:
    public class MyClass
    {	int w=0,h=0;
    	public void someMethod()
    	{	TestCanvas t=new TestCanvas();
    		//	Simply creating the TestCanvas object will call paint() method		//	which will put values in w,h
    		//	Now call your servlet/CGI as follows
    		String url="http://www.mywbsite.com?w="+w+"&h="+h;
    	}
    	class TestCanvas extends Canvas
    	{	public void paint(Graphics g)
    		{	w=getWidth();
    			h=getheight();
    		}
    	}
    }
    i don't think it is any problem..
    Hi,
    Can you check that what will be the actual,values in the w and h..And mutturajb think that what you can do with these 0,0.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  13. #13
    Super Contributor
    Join Date
    Jun 2007
    Location
    Mumbai
    Posts
    539

    Re: How to know device screen size without using canvas.

    Hey, wat grahamhughes said was absolutly correct... Any Displayable can it be Canvas or Screen extended classes gives u heieght and width, using getHeight() and getWidth(). I would suggest u to check the java doc first.
    au revoir
    Prakash Raman

  14. #14
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Re: How to know device screen size without using canvas.

    Hi Raj,

    in my code,TestCanvas is an inner class
    that extends class Canvas.
    Code:
    TestCanvas t=new TestCanvas();
    Creating its object by constructor will call its paint() method,
    which will put values in w and h

    if u want, u can test it
    Vineet Billorey "The Great"

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to know device screen size without using canvas.

    Hi,
    My point was different..read the starting post of this discussion.and indeed you are correct..
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. change the video screen size
    By deepakk in forum Symbian Media (Closed)
    Replies: 10
    Last Post: 2008-07-21, 12:46
  2. GameCanvas size problem on N95 device
    By kalgik in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2008-04-02, 08:46
  3. How to find the MAX - Jar size of the device
    By samurai_kar in forum Mobile Java General
    Replies: 1
    Last Post: 2007-07-25, 20:36
  4. How to display two canvas at time using Sony Ericsson P910 device
    By Ravikumar in forum Mobile Java General
    Replies: 4
    Last Post: 2006-11-10, 10:47
  5. Replies: 7
    Last Post: 2006-09-01, 09:30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×