×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    Unhappy create image rotation on top of screen

    hi..

    i'm trying to build something like a web application where u have 2 frame. there's a banner rotation on top, and normal form below the banner? is it possible to do so in midlet. any idea anyone? i'm using j2me. plzz...help me

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    18

    Re: create image rotation on top of screen

    I guess there is no in-built support for rotating images so you'd have to implement your own rotation function using the Image.getRGB method.

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    Unhappy Re: create image rotation on top of screen

    i can make the image rotate using timer and fetch the image from servlet. but the form below will automatically refresh. for example if i type text in textbox, it will automatically refresh because of the timer. here's my coding...

    Code:
    /*http://www.java2s.com/ExampleCode/J2ME/Downloadandviewapngfile.htm  */
    
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.*;
    
    public class ImageMidletServlet implements CommandListener 
    {
        Display display = null;
        Form f = null;
        //String url = "http://localhost:8080/banner/hp0.gif";
        String url2 = "http://localhost:8080/banner/rotateNumber";       
        String url = "http://localhost:8080/banner/banner";
        Command backCommand = new Command("Back", Command.BACK, 0);
        Command submitCommand = new Command("Submit", Command.OK, 2);
        Command exitCommand = new Command("Exit", Command.STOP, 3);
        private Test test;
        private StringItem stringItem2;
        private TextField txtField;
        private Timer tm;          // Timer
        //private TestTimerTask tt;       // Task
        private int id = 0;
        //String id;
        
    
        public ImageMidletServlet(Display display)
        {
            this.display=display; 
            load();
        }
    
        public void commandAction(Command c, Displayable d) 
        {
            if (c == exitCommand) 
            {
                //destroyApp(true);
                //notifyDestroyed();
            }
            else if (c == backCommand) 
            {
                display.setCurrent(f);
            }
            else if (c == submitCommand) 
            {
                /*test  = new Test(this);
                test.start();*/
            }
        }
    
    
        class Test extends TimerTask implements Runnable
        {
            //ImageMidletServlet midlet;
            private Display display;
    
            public Test(Display display)
            {
                this.display=display;
            }
    
            public void start() 
            {
                Thread t = new Thread(this);
                t.start();
            }
    
            public void run ()
            {
                DataInputStream is = null;
                DataInputStream is2 = null;
                StringBuffer sb = new StringBuffer();
                Image img= null;
                TextBox txtBox = null;
                StringBuffer b = new StringBuffer();
                HttpConnection c2 = null;
                OutputStream os = null;
                
                ++ id;
                
                
                try 
                {
                    
                    c2 = (HttpConnection)Connector.open(url2+ "?bannerid="+id);
                       
                    os = c2.openOutputStream();
                    os.write(("bannerid="+id).getBytes());               
                    os.flush();
                    
                    HttpConnection c = (HttpConnection) Connector.open(url+ "?bannerid="+id);
                    //HttpConnection c = (HttpConnection) Connector.open(url);
                    int len = (int)c.getLength();
            
                    if (len > 0) 
                    {
                        
                        is = c.openDataInputStream();
                        byte[] data = new byte[len];
                        is.readFully(data);
                        
                        is2 = c2.openDataInputStream();
                        int ch;
                        while ((ch = is2.read()) != -1) {
                        b.append((char) ch);
                        System.out.print((char)ch);
                        }
                        
                        //t.setCommandListener(this);                  
                        
                        img = Image.createImage(data, 0, len);
                        Form f2 = new Form("Banner");                     
                        ImageItem imgItem = new ImageItem("", img, 
                        ImageItem.LAYOUT_NEWLINE_AFTER | 
                        ImageItem.LAYOUT_CENTER, null);   
                          
                        f2.append(imgItem);
                        stringItem2 = new StringItem(null, "Moger");
    		    f2.append(stringItem2);
                        txtField = new TextField("Username: ", "", 20, TextField.ANY);
    		    f2.append(txtField);
                        String txtDisplay = b.toString();
                        f2.append(txtDisplay);
                        System.out.print(txtDisplay);
                        display.setCurrent(f2);
                        
                    } 
                    else 
                    {
                        showAlert("length is null");;
                    }
                    is.close();
                    c.close();
                    c2.close();
                } 
                catch (Exception e) 
                {
                    e.printStackTrace();
                    showAlert(e.getMessage());
                }
                
            }
            /* Display Error On screen*/
            private void showAlert(String err) 
            {
                Alert a = new Alert("");
                a.setString(err);
                a.setTimeout(Alert.FOREVER);
                display.setCurrent(a);
            }
            
        }
        
        private void load ()
      {
          tm = new Timer();
          test = new Test(display);
          tm.schedule(test,5000,6000);
                  
      } 
    }

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    5

    Talking Re: create image rotation on top of screen

    With the j2me polish beta 1.3 beta 4 it is possible to and scale images or rotate images in every wanted degree. Check it out J2ME Polish has lot more cool features.

    http://www.j2mepolish.org/downloads/...-1.3-beta4.jar

Similar Threads

  1. HowTo: Update the Idle Screen Image / Phone App Wallpaper
    By mtg101 in forum Symbian User Interface
    Replies: 10
    Last Post: 2006-09-20, 19:09
  2. how to create image beside signal receiver?
    By mohd_izzuan in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2006-03-02, 06:34
  3. my Alert Image is out of the screen
    By romainbaudet in forum Mobile Java General
    Replies: 3
    Last Post: 2005-04-12, 23:02
  4. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  5. DOJA appli -> Create Image from Byte Array
    By teamore in forum Mobile Java General
    Replies: 2
    Last Post: 2004-10-29, 11:14

Posting Permissions

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