Help displaying an image using the canvas!!!!!!!!

Hey guys
I don't know whether I am not grasping some concepts well.I have been going mad trying to get the code working
Here is the code
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
* @author Administrator
* @version
public class MyMIDlet extends javax.microedition.midlet.MIDlet implements CommandListener{
private Display display;
private MyCanvas canvas;
private Command exitcommand = new Command("Exit",Command.SCREEN,1);
private Image source;
public MyMIDlet() {
protected void startApp() throws MIDletStateChangeException{
if (display == null){
initMIDlet();
protected void pauseApp() {
protected void destroyApp(boolean unconditional)throws MIDletStateChangeException {
exitMIDlet();
public void commandAction(Command c, Displayable d) {
if (c == exitcommand){
exitMIDlet();
protected void initMIDlet() {
display = Display.getDisplay(this);
canvas = new MyCanvas(this);
System.err.println("Canvas instiated succesfully");
canvas.addCommand(exitcommand);
canvas.setCommandListener(this);
display.setCurrent(canvas);
public void exitMIDlet() {
notifyDestroyed();
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
public class MyCanvas extends Canvas implements Runnable {
private MIDlet midlet;
private Image offscreen;
private Image currentimage;
private Graphics g;
//MID profile application
/** Creates a new instance of MyCanvas */
public MyCanvas(MIDlet midlet) {
this.midlet = midlet;
try{
currentimage = Image.createImage("/bird0.png");
}catch(IOException e){
System.err.println(e.getMessage());
if (currentimage!= null){
System.err.println("Image create successfully");
}else{
System.err.println("Image not created");
try{
Thread t = new Thread(this);
t.start();
}catch(Execption e){}
protected void paint(Graphics g){
Graphics saved = g;
int x = getWidth();
int y = getHeight();
g.setColor(255,255,255);
g.drawImage(currentimage,x,y,g.TOP|g.VCENTER);
public void run() {
repaint();
I know for a fact that the Canvas class 's paint method is called by the system and not the application. This poses a problem for me because I am not sure how to pass the image to the piant method, so that it can be painted.
When I run the program(using J2ME wtk04), this is the outcome.
Image created succesfully
Canvas instiatiated successfully
null
Here are my questions
1) when is the paint method precisely called by the system?after a reference to the canvas class is created?
2) is it wise to create the image when instiating the canvas class?( initially created the image using a separate thread)-when sould the image be created?
3)how to let the application know when to use the image when painting the display area?
I am just trying the logistics here. It is very crucial to me to understand the bolts of this as the core f my project fouses on the man machine interface development.(For the project, the cilent application is quering for the map using HTTP)
I use a png file of size 161 bytes. Is that too big for testing purposes.
I would all the help that I can get. thanks in advance

1) when is the paint method precisely called by the system?after a reference to the canvas class is created?
After the canvas is set as the current display, and after that, after the repaint() is called.
2) is it wise to create the image when instiating the canvas class?( initially created the image using a separate thread)-when sould the image be created?
It's better to create the image in the very begining of the program e.g. in the midlet initialization. You can call the created image as often as you like later on
3)how to let the application know when to use the image when painting the display area?
you have to tell it :))
you can use if-then, switch, or anything else
and you can use clipping too

Similar Messages

  • How to display an image on the HTML page by using applet

    Dear friends,
    I am now writing an java applet, I want to display an image on the HTML page, and tried the following commands:
    {color:#ff00ff}{color:#000000}Image map; //put in the class definition
    map=getImage(getCodeBase(),"hhh.gif"); //put in the function of init()
    g.drawImage(map,0,300,this); //put in the function of paint(){color}
    {color}
    However, when I run it, the image wasn't displayed at all.
    I hope who guys ever come across this problem could help me to solve it. Thank you in advance!
    Hawaii

    Hi,
    I am no expert on Images
    but
    from personal exp.
    are you sure that map actually contains the image?
    try using
    ImageIcon ii = ImageIcon(String name);
    map = ii.getImage();I saw a tutorial on images i think on sun
    where they use ImageIcon to load the image

  • Image display - How do I display an image using an absolute path?

    How do I display an image using an absolute path in a compiled WebHelp?
    Our developers use RH8 map IDs within our in-house applications to display in a model window created using Telerik Rad Window.
    Unfortunately images disappear from these model windows because RoboHelp removes absolute links to [inserted] images and changes them to relative in the compiled WebHelp.
    How do we overcome this? Is there a solution in RH8?

    I have tried again and changed the path in the topic HTML
    from : ..\..\HelpTopics\Icon_Search.png
    to    :  \HowDoI\Help_CMS\WebHelp\HelpTopics\Icon_Search.png
    I am obviously unable to see it in RH8 as I have removed the relative link so it is "outside" of the project.
    This time, on compilation, it has not stripped out the absolute links. The developer was working with me on this last week and we did have any issue in that they did not hold the absolute link. Most odd!
    Checking the published help it appears to be working in the application, which is great.
    So my apologies for raising the issue but it really did not work last week.

  • Capture an image using the web camera from a web application

    Hi All,
    Could anyone please share the steps what have to be followed for capture an image using the web camera from a web application.
    I have a similar requirement like this,
    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.
    3) Upload the Image to the server from the temporary location.
    Please share the details like, what can be used and how it can be used etc...
    Thanks,
    Suman

    1) Detect the Webcam on the users machine from the web application.(To be more clear when the user clicks on 'Add Photo' tool from the web application)There's not really any good way to do this with JMF. You'd have to somehow create a JMF web-start application that will install the native JMF binaries, and then kick off the capture device scanning code from the application, and then scan through the list of devices found to get the MediaLocator of the web cam.
    2) When the user confirms to save, save the Image in users machine at some temporary location with some unique file name.You'd probably be displaying a "preview" window and then you'd just want to capture the image. There are a handful of ways you could capture the image, but it really depends on your situation.
    3) Upload the Image to the server from the temporary location.You can find out how to do this on google.
    All things told, this application is probably more suited to be a FMJ (Freedom for Media in Java) application than a JMF application. JMF relies on native code to capture from the web cams, whereas FMJ does not.
    Alternately, you might want to look into Adobe Flex for this particular application.

  • How to use the canvas element?

    hi guys,can anyone help on how to use the mx:canvas on the flex mobile project cause they only allow spark components to be used?just want to have a signaturepad using the canvas element..please guys..:(

    Hi All,
    I have  been  able  to  get  the  value  of  a container  element by  using  the  macro  'swc_get_element'   .I  have  used  it  in  the  method  of  my  task   and  saved  the  value  in  a  z-table. For  this  I  have  set  the  'Export' property of that  particular container elemnt .Now  my  problem  is  I  want  a  second  container  element  to  be  stored in  the  database , I  have  set  its  'Export'  property ,  but  inspite  of  that  it  is  not  visible  in  the  task  container.  As  a  result  I  am  not  able  to  access  it  from  inside  my  method  and  unable  to  save  it  in  the  z-table.  So  please  give  me  some  solution.
    Thanks  &  Regards ,
    Samrat Dutta.

  • When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging

    Contexts: I am very competent with GFX and have worked on many projects.
    When dragging an image onto a fresh canvas, the resizing feature presnaps the image into the canvas size. I can confirm that this has not happened to me in previous projects. I've also tested this problem by making a new larger document size and dragging in the same render. It snaps again. I don't want to re-size from the canvas dimensions, I want to resize from the render's original dimensions.

    Ap_Compsci_student_13 wrote:
    ok sorry but doesn't sscce say to post the whole code?the first S is Short, and yes, it needs to be all the code needed to illustrate the problem and let use reproduce it. If you were developing a new Web framework, your example might be short, but for a student game it's very long.

  • Can I crop the image in the canvas

    Can I crop the image from the canvas area so I could make several windows to add some video clips or do I have to just reduce the size of the image and make the composite of the videos. i want to make vertical, rectangle and square composite of several video clips.

    The Time Remap (simulating the corresponding function in FCP) can do basically 2 things:
    a. apply keyframing to the speed of the clip: you can start a clip with speed = 0% (like a freeze frame) and gradually speed up the clip to its end at 100% (standard speed); or viceversa; or start at 100%, slow down to 0% in the middle and back up to 100% at the end. You can apply just any speed variation by keyframing the Speed control.
    b. force the clip to play a frame in a time different than in the original clip; for example you want to have some action originally at time 2secs in sync with a drum roll occurring at frame 2,5secs: just keyframe that action frame at 2,5secs. Then the video clip before 2secs will slow down to meet the drum roll at 2,5secs and then speedup to go back in sync at the end of the clip.
    A few notes:
    - only video is affected, not audio (different from FCE Speed command)
    - the clip length does not change
    - to see the result in the canvas always render: what you see in the viewer is not the final result.
    - instructions on its use are in the download page - if they are not clear let me know.
    As a suggestion you can read Ken Stone's Time Remap up to Time Remap in timeline excluded. It describes this function as implemented in FCP4, but its principles (and some details) are the same as in my filter.
    Let me know...
    Piero

  • I want to display some fields using the BDC and i want to know thruogh whic

    I want to display some fields using the BDC and i want to know thruogh which transaction these fields are displayed.Could you please help me out.

    You can use JFreeChart which is a free and good tool to generate graphs in Java. It has samples and other guides which you can use to get started...

  • How to display an image using MIDP on Palm?

    How can I display an image using MIDP on Palm? The following code works on the Siemens SL45i, but not on Palm:
    public class Test extends List
    Image image = Image.createImage("/images/test.png");
    append("item 1", image);

    Have found the exact same problem when trying to display an image (other then the default (null)) in a list, on a Palm.
    The image displays correctly on a form, but when set on an element in the list, it does not display. (mind you this is in both emulator mode and on the real device)
    It does not seem to be related to size of the image.
    The Sun documetation states, that you should not rely on it been displayed (obviously it's an implementation issue with the Palm, and other devices I have not tried)
    But like to hear definitively from Sun though!

  • I have installed a trial of Adobe illustrator on my macbook pro. I want to trace an image using the custom trace button but can't. Does anyone have any ideas how I could custom trace?

    I have installed a trial of Adobe illustrator on my macbook pro. It is the 2014 release of adobe illustrator. I want to trace an image using the custom trace button.
    I start a new document. Then I place my scanned pencil/colored pencil drawing, in to the document. I have tried scanning and then placing it as a jpeg, bitmap, and tiff file. I have tried scanning and then placing it, in color and in black and white. The scan mode I use is flatbed. Adobe illustrator allows me to select the default button and one of eleven preset buttons (e.g high fidelity photo), but it does not allow me to click the custom trace button. The custom trace button is grey while all the other buttons are white.
    Does anyone have any ideas how I could custom trace?

    It seems pointless to adjust it afterwards because it is then only a couple a pencil lines rather then a full drawing. And how do I adjust it afterwards? Would I do this using the different buttons under the window button?

  • My youtube does not work on safari only when i try to play a video it says "This video is not available on mobile add to playlist" But i am using a mac air 11 inch it is not a mobile. Please Help. i have to use the youtube on firefox or chrome

    my youtube does not work on safari only when i try to play a video it says "This video is not available on mobile add to playlist" But i am using a mac air 11 inch it is not a mobile. Please Help. i have to use the youtube on firefox or chrome. At times it also say QuickTime Player can't open "video.3gp". and
    The file may be damaged or may not be a movie file that is compatible with QuickTime Player. when i try to open a video on youtube on safari

    I too am having the same issue as the OP.
    Your USER AGENT information is Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18
    Every webserver that receives a request from your browser is able to determine the HTTP USER AGENT information unless it has been removed by some software (e.g. firewall) before the request was trasmitted.

  • Help.I uninstalled ios8 using the directions on the web site and now all my apps,mail are gone.I backed up to iTunes first but when I try to sync to get everything back,it starts and then says it has failed.What do I do now.Thanks.Jane

    Help.I uninstalled ios8 using the directions on the web site and now all my apps,mail are gone.I backed up to iTunes first but when I try to sync to get everything back,it starts and then says it has failed.What do I do now.Thanks.Jane

    The first time an iPhone is connected to iTunes that is used to sync with another iPhone or iOS device, you are prompted to transfer the backup for the other iPhone or iOS device or to set up the iPhone as a new iPhone.
    The former does as provided - it transfers the backup for the other iPhone or iOS device to the iPhone replacing all data on the iPhone that is included with the backup being transferred. The latter does nothing allowing you to make your various selections for the iPhone sync preferences with iTunes.
    This is designed to be done right away with a new iPhone.
    If you don't have a backup for the iPhone with iTunes on your computer and don't have an iCloud backup that hasn't been updated since choosing to transfer the backup for your iPod Touch to the iPhone, the data that was on the iPhone is gone.

  • Search help for Web Dynpro using the SAP-search help

    Hi,
    I’m trying to create a generic search help for Web Dynpro using the SAP-search help. It should working so, that I construct a Web Dynpro-component, that gets the data of the search help from the SAP-system, interpreted it and creates the ui-elements and the needed context generic.
    The mapping between the Input field of the customerview and the right search help is to be made with an xml-file, which contains the information: name of the view, the input field, the search-help-name and the name of the field that will be returned.
    The xml-file is reading from a helper-class. That helper-class contains any information, witch need the search help-component as well as the customer-component.
    The initialization takes place in the method wdDoModify of the customer. The call of the search help from the customer should be implement with an Action, witch is bound to a Button(create dynamic in the helper-class behind the input field).
    In a second foot should be create a plugin for eclipse, witch insert the used files (search help component, helper class, …) in the project. In addition it should create the call in the customer generic.
    It would be great if someone can give me a feedback!

    Hi Mike,
    The BlanketAgreement.exe is a reference to the executable that will be created when you compile the solution you created in Part II - Part III. I think there is a mistake in the tutorial because it asks you to name the project 'Blanket' which means that by default the executable will be called Blanket.exe and not BlanketAgreement.exe. The tutorial also misses the step asking you to compile the Blanket project before you go on to create an installer. You should compile your Blanket project in Release mode before creating an installer. By compiling the project you'll get a Blanket.exe file in the bin folder of your Blanket project which you then need to add to the installer per the instructions.
    SAP do offer development courses in some areas and there is training material here on the SDN and on the SAP partner portal (and maybe the customer portal as well). Try searching this forum for 'training' or 'tutorial' and you should get a few links. There's also a development certification.
    Personally I'd recommend you give yourself a little project to work on and just get stuck in
    Kind Regards,
    Owen

  • How can I add a hyperlink to a PDF with OSX 10.9? The "Help" article says to use the "add link" feature under "edit." It's not there.

    How can I add a hyperlink to a PDF with OSX 10.9? The "Help" article says to use the "add link" feature under "edit." It's not there. I could add links w/ the previous OS. Time sensitive project.

    Which application are you using?
    Clinton

  • HT5891 Is there a way to remove the menu bar from a secondary display while still using the "Displays have separate spaces" mode?

    Is there a way to remove the menu bar from a secondary display while still using the very useful "Displays have separate spaces" mode?
    The reason I ask is that most full-screen video playback in most applications, from iTunes to Flash/Silverlight plugins do not take up the full screen, instead leaving space for the menu bar (in the case of iTunes) or leaving the menu bar present on top of the video (for fullscreen Flash/Silverlight videos).
    This is annoying for several reasons ranging from the obvious distraction factor to the fact that 1080p video is not played back at native resolution on a 1080p display.
    If there is no way to disable this functionality while maintaining separate spaces, I would (humbly) suggest that a future update to Mavericks allow non-Lion-style* full-screen apps to take over the entire display.
    *Lion-style full-screen apps are those that animate into a full-screen mode when the opposing-arrows full-screen button in the upper-right-hand corner of the window is pressed.

    No. Turning that off reverts to the old display setup. You have one desktop spanned across all displays. The menu bar appears on the primary display only.

Maybe you are looking for