i am trying to upload a image in canvas bt it is not responding. only black screen of canvas is shown, suggest me solution..
Expand|Select|Wrap|Line Numbers
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.io.IOException;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- import java.util.*;
- public class fb_Midlet extends MIDlet {
- Display dis;
- fb_login canvas;
- Form form;
- Image image;
- ImageItem imageitem;
- public fb_Midlet()
- {
- dis= Display.getDisplay(this);
- canvas = new fb_login(this);
- form = new Form("image for splash");
- try {
- image = Image.createImage("FB.png");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- imageitem = new ImageItem(null, image,
- ImageItem.LAYOUT_LEFT , "My Image");
- form.append(imageitem);
- }
- public void startApp() {
- Timer obj = new Timer();
- TimerTest obj1= new TimerTest();
- obj.schedule(obj1,1000);
- dis.setCurrent(form);
- }
- public void pauseApp() {
- }
- public void destroyApp(boolean unconditional) {
- }
- public void exitMidlet()
- {
- destroyApp(true);
- notifyDestroyed();
- }
- class TimerTest extends TimerTask
- {
- public void run()
- {
- dis.setCurrent(canvas);
- }
- }
- }
- import java.io.IOException;
- import javax.microedition.lcdui.*;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Balram
- */
- public class fb_login extends Canvas implements CommandListener{
- fb_Midlet fb_midlet;
- Command exit;
- Image image;
- Image TmpImp;
- public fb_login(fb_Midlet fb_midlet)
- {
- exit = new Command("exit",Command.EXIT,1);
- this.fb_midlet= fb_midlet;
- try {
- image = Image.createImage("images.jpg");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- addCommand(exit);
- setCommandListener(this);
- }
- protected void paint(Graphics g) {
- if(image != null)
- {
- g.drawImage(image, 0, 0,Graphics.VCENTER);
- }
- }
- public void commandAction(Command c, Displayable d) {
- if(c==exit)
- {
- fb_midlet.exitMidlet();
- }
- }
- }
Thanks:
Balram Singh
+919453037228