Rendering Canvas with Images - Display is flashing

Hello everybody.
I have created a Canvas within a Frame. This canvas contains many static pictures (.jpg and .png) and static texts. I also print out next to some of these images and static texts some values as strings using drawString.
These values are changed depending on some calculations taking place.
The problem is that the overall GUI is flashing periodically, and it does not look very nice.
How can I render the whole GUI without these flashing problems?
I write down my way:
public class myCanvas extends Canvas implements Runnable
public myCanvas()
//This is a THREAD
        Thread t=new Thread(this);
        t.start(); //start it
public void paint(Graphics g)
        //Static image and static text
        g.drawImage(image2, 1,5, this);
        Font font=new Font("Tahome",Font.BOLD,14);
        g.setFont(font);
        g.drawString("Value:",62,40);
public void update(Graphics g)
        Font font=new Font("Tahome",Font.BOLD,20);
        g.setFont(font);
// I 'd like to update only the values next to static image and static text from paint()
        g.drawString(cntTester+" bpm",148,42);
        cntTester++;
public void run()
        //Firts wait for the images to fully load and paint
        try
            for (int i=0;i<4;i++)
                mediaTracker.waitForID(i);
        catch (Exception ex)
  while (isPlay == true)
            try
                Thread.sleep(2000); //2 secs
            catch(Exception ie)
            this.repaint(140,25,80,25); //Repaint specific sections
        }The above Canvas is instantiated within a Frame.
I really appreciate nay help and guidelines.
Regards,
kalgik

The flashing is really depends on the Thread.sleep() timeout.
import java.awt.*;
public class myCanvas extends Canvas implements Runnable
    //Declaration of variables
    private int cntTester=0; //It used only for test, to update values for parameters
    private MediaTracker mediaTracker;
    private Color colour;
    private Font font14;
    private Font font20;
    private Thread t;
    public myCanvas()
        colour=new Color(0x000000); //-> Black colour for letters
        font14=new Font("Tahome",Font.BOLD,14);
        font20=new Font("Tahome",Font.BOLD,20);
        this.setVisible(true);
        this.setBounds(2,2,235,315);
        init();
        //This is a THREAD
        t=new Thread(this);
        t.start(); //start it
   public void run()
        //First wait for the images to fully load and paint
        try
            for (int i=0;i<1;i++)
                mediaTracker.waitForID(i);
        catch (Exception ex)
        while (isPlay == true)
            try
                Thread.sleep(2000);//The flashing depends on this timeout (2 seconds).
            catch(Exception ie)
            myupdate();
            repaint(500,69,20,170,134); //repaint specific area of Canvas
    //I got rid of the overidden method update(Graphics g)
    public void myupdate()//Graphics g)
        cntTester++; //Simply increment the value of this variable
    public void init()
       mediaTracker = new MediaTracker(this);
        //Image Heart rate
        String imageHeartRateName="Images/Icons/HeartRate/heart-64x64.png";
        imageHeartRate = Toolkit.getDefaultToolkit().createImage(imageHeartRateName);
        mediaTracker.addImage(imageHeartRate, 0);
   public void paint(Graphics g)
        super.paint(g);
        System.out.println("Passing from [paint]");
        g.setColor(colour);
        //Heart rate:
        g.drawImage(this.imageHeartRate, 1,5, this);
        g.setFont(font14);
        g.drawString("Heart Rate:",62,40);//String , coordinates
        g.setFont(font20);
        g.drawString(cntTester+" bpm",148,42);//String , coordinates
}

Similar Messages

  • Experiencing problem with image display in LR5

    I have an intermittent problem with images displaying and exporting in LR. It just began a couple of months ago and is totally random - will do it with RAW (CR2) or JPG. It displays this way in all modules - Library, Develop, Slideshow....The image displays fine in a non-Adobe image viewer (Faststone or Windows Viewer). I've reloaded LR5 and PSCC and is still persists. I know the image file is fine. It also has begun effecting older images that were showing up just fine a while ago. I just loaded about 200 images and maybe 3 or so have this viewing problem in LR & PS. Has anyone else experienced it and have a suggested fix? My graphics card has the latest drivers and shows no problems with other applications. Here is the same image - one a jpg export from Lighroom, the other a save as jpg from Faststone. HELP!

    This is almost always a hardware problem, causing corruption of the file. The difference you see between Lightroom and other software is that Lightroom is accessing the full RAW image, while the other software is trying to read the embedded JPG preview.
    To figure out exactly what hardware is the problem, you need to try different transmission paths and hardware ... different camera cards, different card readers or USB cables/USB ports, different hard disks, etc. Eventually you should be able to isolate the problem.

  • How to display html content with image in Adobe Flash and Flex mobile project?

    Hi,
      I have a html content with image in it. How to display it in Adobe Flash Builder and Flex mobile project? Which control needs to be used for this?

    Hello,
    The only current way is to use an iFrame, or if you only need some html tags you could use the Text Layout Framework.
    Here this is the iFrame approach:
    http://code.google.com/p/flex-iframe/
    If the swc do not work in Flex4 just use its ource code which works...
    ...it is basically based on this:
    http://www.deitte.com/archives/2008/07/dont_use_iframe.htm
    see also and vote, please:
    http://bugs.adobe.com/jira/browse/SDK-12291
    http://bugs.adobe.com/jira/browse/SDK-13740
    Regards
    Marc

  • **Urgent**: GO_ITEM to pop-up CANVAS with IMAGE in Sun JRE gives error

    Our Forms 10g Environment is this: Forms [32 Bit] Version 10.1.2.0.2 (Production) using Sun JRE i.e. Java Plug-in 1.6.0_06
    Problem is that when we try to navigate to a canvas (from a Button) which has an IMAGE ITEM the form is exited. This happens in every form which has a canvas with an image.
    i.e. In Button, we have code: Go_Item('block123.button1'). Button1 is also in that pop-up canvas.
    Even GO_BLOCK gives the same result.
    If the image is in the same canvas as the button which has GO_ITEM code, then it works.
    Of course this whole things works fine in JInit. But we need to run in Sun JRE.
    Is this a Bug?? Any help would be greatly appreciated.

    christian erlinger wrote:
    Well, as you are on 10.1.2.0.2 I strongly suggest that you apply the latest Patchset (10.1.2.3) the latest CPU Patches and the latest merge Patches. A lot of focus related things are fixed in those patches.
    cheersI will do this and let u know thans.

  • Problem with image display

    here is a sample code i need the image to be displayed on button click but the following code is giving some exceptions.
    could u please make out where i am going wrong
    import java.awt.BorderLayout;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    public class NewJApplet extends JApplet implements MouseListener{
    imagePanel imp;
      private JButton draw;
         * Initialization method that will be called after the applet is loaded
         * into the browser.
        public void init() {
            imp=new imagePanel(this.getGraphics());
             draw=new JButton("draw");
            addMouseListener(this);
            makegui();
        public void makegui()
            setLayout(new BorderLayout());
            add(BorderLayout.NORTH,draw);
            add(BorderLayout.CENTER,imp);
            imp.setVisible(false);
        public void mouseClicked(MouseEvent e) {
           if(e.getSource()==draw)
               System.out.println("Clicked");
               repaint();
           imp.setVisible(true);
        public void mousePressed(MouseEvent e) {
           // throw new UnsupportedOperationException("Not supported yet.");
        public void mouseReleased(MouseEvent e) {
           // throw new UnsupportedOperationException("Not supported yet.");
        public void mouseEntered(MouseEvent e) {
           // throw new UnsupportedOperationException("Not supported yet.");
        public void mouseExited(MouseEvent e) {
          //  throw new UnsupportedOperationException("Not supported yet.");
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.Toolkit;
    import javax.swing.JPanel;
    public class imagePanel extends JPanel {
        private Image img=null;
        Graphics gmain;
        public imagePanel(Graphics g)
            this.gmain=g;
         img=Toolkit.getDefaultToolkit().getImage("C:\\Documents and Settings\\sakshi\\My Documents\\NetBeansProjects\\Imagetry1\\1.jpg");
        public void paintComponent(Graphics g)
             gmain.drawImage(img, 100, 100, null);
            System.out.println("printing ");
    }

    >
    here is a sample code i need the image to be displayed on button click but the following code is giving some exceptions.
    could u please make out where i am going wrong>In addition to the valuable information on the first reply..
    1) This applet is attempting to read a File. While it is possible for a signed/trusted applet to create a File and access it, it is usually impractical for an applet, since the File path will not point to anywhere on the server, but to a place on the client file-system. Instead look to use URLs for resources in applets. The Applet class has handy methods for forming URLs to resources relative to the code base or document base. You might need to alter the imagePanel constructor to accept that URL.
    2) BTW - imagePanel should be called ImagePanel. The Java nomenclature (naming) conventions indicate EveryWordUpperCaseClass names, camelCaseMethod() names, and camelCaseAttribute names.
    3) Sentences should start with a single upper case letter. This helps the reader to quickly scan text, looking for ways they can help. You would not want to make it harder for people who are trying to help, would you?
    4) The word 'I' should be always upper case, always.
    5) Please take the effort to spell words fully. E.G. 'u' -> 'you'. For the sake of saving two letters, it makes people appear to be lazy dopes.

  • Problems with image display

    Hi, I am new to J2ME, and this forum as well. I am writing a small MIDlet to display an image using WTK1.4. The problem is that the image (500X400) is not being displayed wholly on the emulator screen. In fact, only a very small portion of it is being displayed.
    Is there any way to resize (scale down) the image, or make the screen scrollable (up-down, left-right) so that the entire image can be displayed? Help will be highly appreciated.
    Thank you.

    In midp1 you can not scale images

  • Editing in PS CS 5 / re-save edited version back to Aperture problems with image display

    I use Aperture and send images into CS 5 but since latest Aperture update the images don't always display the adjusted version.  A re-start of Aperture is required. Any suggestions appreciated.  Never had any issues before. 

    If you are running AP 3.2.3, you may be experiencing a known issue:
    http://support.apple.com/kb/TS4237
    We are waiting on a fix from Apple.

  • LabVIEW 8.2 Image Display bug

    Hi all,
    Description : Trying to create a constant by right
    clicking on an image display (controls palette > vision > image
    display) causes labview to crash.
    LV
    version : 8.20 only, didn’t exist in 8.0.1 and earlier !
    Same bugg happens:
    with image display (classic),
    when trying to create a constant from a
    local variable of these indicators,
    when trying to create a constant on the
    connector of a subVI for these indicators.
    Message Edité par TiTou le 10-23-2006 08:38 AM
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
    Attachments:
    bugg_image_display.png ‏234 KB

    Hello,
    Thank you for reporting this.  A CAR has been filed on the issue - for reference the CAR ID is 4308NMSQ.
    Best Regards,
    JLS
    Standard Response:
    This was reported to R&D (4308NMSQ CAR ID) for further investigation. Thanks for the feedback!
    Best,
    JLS
    Sixclear

  • Can I make an image display instead of flash slideshow on explorer with high security?

    I am a total flash beginner.  I created a simple flash slideshow that I want to appear on my website.  It works fine in firefox., but when viewed in explorer with high security, nothing displays unless the viewer specifically allows it. The slideshow is very prominent, and the site looks very bad when only an x shows up.   Is it possible to have a static image display in place of the slideshow, and then have the slideshow start if the viewer allows it? Is there any other way to get around this? 
    Thank you for any assistance.
    EJ

    Have you tested it with IE online or only locally?  Locally IE will usually prohibit displaying Flash content.

  • Need help displaying images with List component for Flash CS4 (ActionScript 3.0)

    Hi folks:
    I am an inexperienced user of Flash CS4 Pro (v10.0.2). I am attempting to use the List component with ActionScript 3.0 to make a different image display when a user clicks each item in a list.
    I did find a tutorial that showed me how to make different text display using a dynamic text box and the following ActionScript:
    MyList.addEventListener(Event.CHANGE, ShowSelectedItem);
    function ShowSelectedItem(event:Event):void {
        ListText.text=MyList.selectedItem.data;
    ...where My List is the instance of the List component and ListText is the dynamix text box. In this case, the user clicks an item in the list, defined by the label value in the dataProvider parameter of the List component, and text displays as defined in the data value in the dataProvider parameter.
    However, as I mentioned to start, what I really want to do is make images display instead of text. Can anyone provide me the steps to do this?
    I appreciate your help (in advance)!!
    Cindy

    Hi...thanks for responding! I was planning on using images from the Library, but if there is a better way to do it, I'm open. So far, I just have text in the data property. This is part of my problem. I don't know what I need to put in the data value for an image to display. Do I just put the image file name and Flash will know to pull it from the Library? Do I need to place the images on the stage on different frames? I apologize for the "stupid user" questions, but as you can tell, I'm a newbie.
    Appreciate your patience and any help you can offer!
    Cindy

  • BPM Workspace can't display the flash movie with IE

    Hi
    We have the following problem, we have a BPM project with a flash screen, when we execute the project in the workspace of BPM studio we can see the Flash, but when we published the project in BPM Enterprise , the workspace can't display the flash movie, it just display the panel without buttons and fields. This happen just in Internet Explorer, in other browsers we can see the flash.
    Any idea or solution ??
    Thanks in advance

    Actually, I got it working now...
    It seems that I have to have all the files in the same folder
    as the page it displays on!
    Historically I would dump a standard flash clip (not a
    converted movie with buttons) into the /images folder.
    I tested this intitally in a /video folder (just to keep all
    the files in one place) which would display the clip but not the
    buttons but as soon as I moved the files in the same directory as
    the page itself (which is the main index.html) it worked fine!
    So if anyone does read this is there a reason for that as I
    would like to keep everything in separate folders!
    Cheers, J

  • Flash SDK and MacBook Pro with Retina display major issues

    Hello,
    Apple has recently released Macbook Pro's with Retina displays.
    I have tested my Flash application on the new laptop, and this is what I observe:
    My Flex SDK Flash application looks blurry and strange when I try to check it out from any Macbook Pro with Retina display, while looking sharp and OK from all other machines.
    On this screenshot you can sort of see the issue:
    http://i.imgur.com/UXHd4.png
    (Expand the image to the actual size, and compare the Flex SDK components with browser labels. Browser labels look crisp, Flex SDK components look a little bit blurry.)
    Please fix this issue.
    Andrey

    Sure. LR 4.3 even specifically adds Retina support...
    Mylenium

  • Display an image instead of Flash?

    I'm a little green when when it comes to this stuff.
    I have a site that has a couple of Flash elements that show
    fine. Due to the network security on my work computer, it means
    they don't show when viewed from there.
    Is there a way to display an image if the Flash element
    cannot be displayed?
    Thanks in advance of any help.

    Have you tested it with IE online or only locally?  Locally IE will usually prohibit displaying Flash content.

  • Display problems in Mail messages with image attachment

    Issue: Seeing intermittent display problems in Mail messages with image attachments
    Annoyance level: minor, but Apple techs need to pass it along
    Details: Regardless of mail client sending to iPhone (Outlook, OWA, Yahoo, Gmail) there are intermittent and what appear to be random occurrances of the pic being half rendered and/or the pic never loading (followed by message saying it can't be retrieved from server). In some instances the picture then appears fully rendered without a problem. Note: Image sizes varied from 14KB to 450KB

    Hi,
    I'm not familiar with C#, but if possible try the following:
    1. Removing all thead and tbody tags from the body of the message.
    2. Changing all inline CSS to embedded CSS.
    I've seen a user said the message stopped showing up after making the changes.
    If the issue persists, please note, since Outlook 2007, Outlook opens the HTML Email and converts it to Microsoft Word format before displaying it to the user. What happens during this process is that many CSS attributes and HTML support is completely removed.
    Some of the most notable absences are background-image, and padding and margin support. Hardly can we do much about this, so the message "If there are problems with how this email is displayed, click here to view it in a web browser" is actually
    a good workaround when we face this problem.
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Are there other internet browsers that work well displaying websites with a lot of Flash content?

    Other than the browser that came on the Samsung Droid Charge....
    Are there other internet browsers that work well displaying websites with a lot of Flash content? 
    Thanks in advance!

    I use Dolphin Browser 6.0. Its faster than 5.0 and has no issues with Flash.  I have used flash and used the Beta 6.0 and now the actual released version. Its the best so far. It has tabs like a normal computer browser and even has a gesture feature to do scrolling. 
    Others are Firefox which has NO flash. Then there is SkyFire which is ok, uses its servers to compress data and show it on your phone, its quick but I found the quality of images not as good as stock. 
    Opera Mobile and Mini do the same as skyfire.
    I personally just didnt care for Xscope of Miren browsers.  Didnt care for the feel of Xscope and Miren was developed in China and is modeled after Iphone Browser. 
    Try em all if you want, biggest benefit of the aftermarket browser is you can sync certain accounts (dolphin with google, firefox with firefox) and instead of storing the Cache info using phone memory you can now save the data and the web browser on the SD card. 

Maybe you are looking for

  • Apple Mail Search is acting strange

    Hello. I have been having some major issue with Apple Mail (6.5) in its search function. I have been a heavy user of Apple Mail (over 15,000 emails on the program- and archived every year) for many years, and never had this issue. When I search for a

  • Can you use iCloud to transfer data from one iPod to another?

    Hi, I'm a newbie to Apple. I'm getting another iPod touch with bigger storage, the only data I care about is Clash of Clans. Can I use iCloud to back up the data, and restore it to the iPod I want? Please help, I don't want to lose my data without th

  • Time Capsule vs NAS attached to AEn

    This may be a hard one to answer without having the product but can anyone weigh in on whether using the Time Capsule drive would have faster access times than say a Lacie network drive attached to Airport Extreme N? Reason is that keeping our photo

  • Had to do a restore/ cant find my music

    I purchased a couple songs and audio books and had to do a restore point to computer and now I dont know where my purchased items are or to even login to the site, to bring up my music and i have not even moved it to my ipod cus I need help with that

  • AE Crashes When Opening Adobe Media Encoder

    My after effects started crashing whenever I opened up encoder a few hours ago. I thought taking a break and then trying it again would solve it, but it keeps crashing. he weird part is that it was working perfectly fine yesterday but now, it refuses