×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Lwuit form Invalidate

    Hi All,

    I created a lwuit based form and working fine now I want to invalidate the whole form when the screen orientation changes so I used changesize method and invalidate the whole form but nothing happens they are not placed according to changed coordinates
    Regards,
    Saurabh

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    Any one here any idea of solution to my problem
    Regards,
    Saurabh

  3. #3
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Lwuit form Invalidate

    Quote Originally Posted by ingsaurabh View Post
    Hi All,

    I created a lwuit based form and working fine now I want to invalidate the whole form when the screen orientation changes so I used changesize method and invalidate the whole form but nothing happens they are not placed according to changed coordinates
    ASAIK, LWUIT supports orientation change implicitly. You don't have to do it anything for it. See this link:
    http://forums.java.net/jive/message....ssageID=320019

  4. #4
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    yes you are right lwuit change it accordingly but if set the margin to 20 in landscpe form it should change to somwhat less value in landscape form by using height and width but its not happening
    Regards,
    Saurabh

  5. #5
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Lwuit form Invalidate

    Quote Originally Posted by ingsaurabh View Post
    yes you are right lwuit change it accordingly but if set the margin to 20 in landscpe form it should change to somwhat less value in landscape form by using height and width but its not happening
    That you can handle easily. Don't hardcode the value of margin, use a class level variable instead. Now, override sizeChanged() method of the form that will inform you of orientation change. Inside sizeChanged method put different values in the variable as per orientation change.

    I hope you got my point !!

  6. #6
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    yeah I know this method but did it in different manner what I did make class that extends forms and define all variables used in whole project in that class only and use them and in sizechanged method of that class change the width and height accordingly all values even changes but since the form doesnt invalidates it does show the changes what I think
    Regards,
    Saurabh

  7. #7
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Lwuit form Invalidate

    Quote Originally Posted by ingsaurabh View Post
    yeah I know this method but did it in different manner what I did make class that extends forms and define all variables used in whole project in that class only and use them and in sizechanged method of that class change the width and height accordingly all values even changes but since the form doesnt invalidates it does show the changes what I think
    Did you call repaint() at the end of sizeChanged() method ? It can serve your purpose.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: Lwuit form Invalidate

    Try Calling repaint() or this.show() at the end of sizeChanegd() method.

    thanks,
    ~Amitabh

  9. #9
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    HI gaurav and amitabh both repaint and show method doesnt produce the desired results if you say I can post my code here for review
    Regards,
    Saurabh

  10. #10
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Lwuit form Invalidate

    Quote Originally Posted by ingsaurabh View Post
    HI gaurav and amitabh both repaint and show method doesnt produce the desired results if you say I can post my code here for review
    I've used it successfully many times. It must work. Please provide the code for review.

  11. #11
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    hi Gaurav I have used every thing but unable to solve the bug BTW here is my code might you find the bug

    PHP Code:
    public class LoginScreenForm extends Form implements ActionListener
    {
        private static 
    LoginScreenForm instance;
        
    Command exitCommand = new Command("Exit");
        
    Command viewIpCommand = new Command("View IP");

        public static 
    int   screenWidthscreenHeightimageWidthimageHeightx20,
                            
    x10x18x28y20x90y100;

        
    LoginScreenForm()
        {
            
    super("Login");
            
    instance this;
            
    Calculate();
            
    this.setScrollable(false);
            
    this.addCommand(exitCommand);
            
    this.addCommand(viewIpCommand);
            
    setCommandListener(this);
            
    loadScreen();
        }

        public 
    void loadScreen()
        {
            
    this.setLayout(new BorderLayout());

            
    Container centralPanel = new Container(new BoxLayout(BoxLayout.Y_AXIS));

            
    Container usernameBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
            
    Container passwordBar = new Container(new BoxLayout(BoxLayout.X_AXIS));

            
    Label usernameLabel = new Label("Username");
            
    usernameLabel.getStyle().setBgTransparency(0);
            
    TextField usernameText = new TextField();

            
    Label passwordLabel = new Label("Password ");
            
    passwordLabel.getStyle().setBgTransparency(0);
            
    TextField passwordText = new TextField();
            
    Button loginButton = new Button("Login");
            
    loginButton.addActionListener(new ActionListener()
            {
                public 
    void actionPerformed(ActionEvent evt)
                {
                    
    HomeScreen.getInstance().show();
                }
            });
            
            
    loginButton.getStyle().setMargin(y200x90x90);

            
    usernameBar.addComponent(usernameLabel);
            
    usernameBar.addComponent(usernameText);
            
    passwordBar.addComponent(passwordLabel);
            
    passwordBar.addComponent(passwordText);

            
    centralPanel.addComponent(usernameBar);
            
    centralPanel.addComponent(passwordBar);
            
    centralPanel.addComponent(loginButton);

            
    centralPanel.getStyle().setMargin(y100,0x10x10);

            
    addComponent(BorderLayout.CENTERcentralPanel);
        }

        public 
    void actionPerformed(ActionEvent ae)
        {
            if(
    ae.getCommand() == exitCommand)
                
    GalaxyMidlet.midlet.destroyApp(true);
            else if(
    ae.getCommand() == viewIpCommand)
            {
                
    ViewIP.getInstance().show();
            }
        }

        public static 
    LoginScreenForm getInstance()
        {
            if(
    instance == null)
            {
                
    instance = new LoginScreenForm();
            }
            return 
    instance;
        }
        public 
    void Calculate()
        {
            
    screenWidth this.getWidth();
            
    screenHeight this.getHeight();
            
    y20             =   (int)(screenHeight/16);    //20
            
    x90             =   (int)(screenWidth/2.66);    //90
            
    y100            =   (int)(screenHeight/3.2);    //20
        
    }

        protected  
    void sizeChanged(int wint h)
        {
            
    Calculate();
        }


    Regards,
    Saurabh

  12. #12
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: Lwuit form Invalidate

    try
    PHP Code:
     
        
    public void Calculate(int screenWidth int screenHeight 
        { 
            
    y20             =   (int)(screenHeight/16);    //20 
            
    x90             =   (int)(screenWidth/2.66);    //90 
            
    y100            =   (int)(screenHeight/3.2);    //20 
        


        protected  
    void sizeChanged(int wint h
        { 
            
    Calculate(w,h); 
            
    this.repaint();
            
    this.show();
        } 
    thanks,
    ~Amitabh

    Also see: http://discussion.forum.nokia.com/fo...d.php?t=197655

  13. #13
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Lwuit form Invalidate

    I have already tried that but of no use
    Regards,
    Saurabh

  14. #14
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Lwuit form Invalidate

    Quote Originally Posted by ingsaurabh View Post
    I have already tried that but of no use
    Try this:

    PHP Code:
     public void Calculate(int screenWidth int screenHeight )  
        {  
            
    y20             =   (int)(screenHeight/16);    //20  
            
    x90             =   (int)(screenWidth/2.66);    //90  
            
    y100            =   (int)(screenHeight/3.2);    //20  
        
    }  

        protected  
    void sizeChanged(int wint h)  
        {  
            
    Calculate(w,h);  
            
    loginButton.getStyle().setMargin(y200x90x90); 
            
    centralPanel.getStyle().setMargin(y100,0x10x10); 
            
    this.repaint(); 
            
    this.show(); 
        } 
    I guess the variables have been recalculated but have not been applied again. So try this and let me know.

Similar Threads

  1. draw graph in Lwuit Form
    By yatin.frankline in forum Mobile Java General
    Replies: 11
    Last Post: 2010-04-06, 11:23
  2. need to put canvas in LWUIT Form
    By yatin.frankline in forum Mobile Java General
    Replies: 5
    Last Post: 2010-04-05, 13:23
  3. LWUIT 1.3 : bad form refresh
    By frasene in forum Mobile Java Tools & SDKs
    Replies: 7
    Last Post: 2010-02-06, 18:54
  4. How to use replace method of LWUIT form?
    By neeraja.nokia in forum Mobile Java General
    Replies: 0
    Last Post: 2009-01-24, 04:24
  5. Form troubles
    By matdodgson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-06, 10:49

Posting Permissions

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