Results 1 to 1 of 1
  1. #1
    nikolakis1987 is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default Canvas context dissapears

    Part of my canvas context or all context disappears disappears when JFrame is minimised, or dragged out of screen margins or another window is over it.

    At the moment I have a GUI class that extends JFrame (NetBeans JFrame design) and that creates the whole GUI along with a canvas. All the objects in the GUI class are JButtons, JTextFields and basically a lot of "JItems" apart from the Canvas in the centre of the GUI.

    Then with a START button I pass the current canvas object into another class (AnimateCanvas) and initiate some drawing on it.

    This is what approximately happens:

    ************************************************** ***********
    class AnimateCanvas extends Canvas{

    Graphics graphics;

    public AnimateClass(Canvas canvas){
    graphics = canvas.getGraphics();

    paint(Graphics g) {
    // all drawings are made in this method only.

    } else{


    void doSomething(){


    My animation works like I want it to work except like I said in the above conditions. (i.e. JFrame is minimised or under another window or dragged outside screen margins).
    As far as i know all items are lightweight too so I don't think it's a lightweight heavyweight issue.

    Using repaint() instead of paint(graphics) has proved to erase all my drawings on the canvas.

    Any ideas why I am losing part of my canvas drawings?

    Thank you,

    Last edited by nikolakis1987; 08-04-2011 at 04:47 PM.

Similar Threads

  1. iReport/JasperReports:Column content dissapears
    By mmontest in forum Advanced Java
    Replies: 0
    Last Post: 03-25-2011, 03:13 PM
  2. Replies: 0
    Last Post: 07-05-2009, 12:31 PM
  3. Using a Canvas
    By a_klasanov in forum CLDC and MIDP
    Replies: 3
    Last Post: 12-08-2008, 10:36 AM
  4. Canvas Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 02:22 PM
  5. Using SWT Canvas
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:06 AM

Posting Permissions

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