Applet Canvas / Panel Problem

Discussion in 'Java' started by lltaylor, May 6, 2004.

  1. lltaylor

    lltaylor Guest

    Hello,

    I have written a threaded tree control which is displayed in an
    applet.
    The way it works is that the reusable control is a canvas.
    The control is created in an applet and the canvas is drawn onto a
    panel.

    Things work great when the content is static, however when the tree
    structure
    is changed - i.e. someone adds a folder or deletes a file problems
    creep in.

    I have no problem updating the tree (which is the canvas) but after
    every change the new canvas needs to be placed on the panel.

    I have tried

    Panel.remove(tree);
    Panel.add("Center", tree);
    (there are three panels in total - the other two have scrollbars in
    them)

    But this does not appear to update when changes are made.

    So I have tried

    Panel.removeAll();
    Panel.add("Center", tree);
    Panel.add("South", horizontalScrollbar);
    Panel.add("East", verticalScrollbar);

    This does the update perfect however I get a flickerwhen the update
    occurs.

    So basically my question is in two parts?

    Can anyone suggest how I can update the panel to avoid it flickering?
    Or anyone suggest an alternative way of organising my tree so it
    remains a generic control but has a better method of updating?

    does that make sense?

    Any suggestion greatfully recieved.

    Regards

    Lloyd
     
    lltaylor, May 6, 2004
    #1
    1. Advertising

  2. On 6 May 2004 08:08:50 -0700, lltaylor wrote:

    > I have written a threaded tree control which is displayed in an
    > applet.


    <http://www.physci.org/codes/javafaq.jsp#cljg>

    > I have tried...

    <code snippets>

    > So I have tried

    <code snippets>

    > This does the update perfect however I get a flickerwhen the update
    > occurs.


    Those two things seem to contradict.
    Or is it just I have been up for 30 hrs??

    > So basically my question is in two parts?

    ...
    > does that make sense?


    Not much. Though maybe it is just me. (shrugs)

    > Any suggestion greatfully recieved.


    <http://www.physci.org/codes/sscce.jsp>

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, May 6, 2004
    #2
    1. Advertising

  3. In article <>, lltaylor wrote:
    > Hello,
    >
    > I have written a threaded tree control which is displayed in an
    > applet.
    > The way it works is that the reusable control is a canvas.
    > The control is created in an applet and the canvas is drawn onto a
    > panel.
    >
    > Things work great when the content is static, however when the tree
    > structure
    > is changed - i.e. someone adds a folder or deletes a file problems
    > creep in.
    >
    > I have no problem updating the tree (which is the canvas) but after
    > every change the new canvas needs to be placed on the panel.
    >
    > I have tried
    >
    > Panel.remove(tree);
    > Panel.add("Center", tree);
    > (there are three panels in total - the other two have scrollbars in
    > them)


    In your description you wrote that "the new canvas needs to be placed
    on the panel", but in the code snippet you add the same component
    (named tree) instead of removing the existing component and adding a
    new one. Do you have a "new canvas" or not?

    > But this does not appear to update when changes are made.


    There is no update because nothing has changed about the components that
    would cause and update. If the contents of the component has changed,
    but it size has not changed, invoke repaint on the component.

    > So I have tried
    >
    > Panel.removeAll();
    > Panel.add("Center", tree);
    > Panel.add("South", horizontalScrollbar);
    > Panel.add("East", verticalScrollbar);
    >
    > This does the update perfect however I get a flickerwhen the update
    > occurs.


    If it updates perfectly, chances are there is code outside of this
    snippet that is causing the update.

    > So basically my question is in two parts?
    >
    > Can anyone suggest how I can update the panel to avoid it flickering?


    Go to you favorite Internet search engine and search for the terms
    "double bufferring", "java", and "awt".
     
    A. Bolmarcich, May 6, 2004
    #3
  4. lltaylor

    lltaylor Guest

    In your description you wrote that "the new canvas needs to be placed
    on the panel", but in the code snippet you add the same component
    (named tree) instead of removing the existing component and adding a
    new one. Do you have a "new canvas" or not?

    But this does not appear to update when changes are made.

    There is no update because nothing has changed about the components
    that
    would cause and update. If the contents of the component has changed,
    but it size has not changed, invoke repaint on the component.

    -----

    OK, the way the code works which I didn't make apparent.
    The snippet of code is in a method which is called every time a change
    is made to the tree. Just above the snippet I provided I create a new
    instance of the tree object (which is a canvas).

    So what I am trying to do is remove the old one and replace it with
    the newly created one.

    What I try to initailly is just remove the the panel with the tree on
    it and then add the new tree, but this does not update.

    However if I remove all the panels on the applet with the remove all
    and then
    add them all on again - the update occurs - but with flickering.

    It is not a double buffering issue because in the class where I
    actually draw
    the tree onto the canvas - all the double buffering is done there.

    I paint the tree onto a canvas - because I am using the tree for
    different implementations so I need a generic tree control, and I am
    painting it onto a panel becase I need it to be scrollable.

    Does anyone know of a way of stopping the flickering when I am
    swapping panels, or is there a better way I can architect this?

    Regards

    Lloyd


    9.net (A. Bolmarcich) wrote in message news:<9.net>...
    > In article <>, lltaylor wrote:
    > > Hello,
    > >
    > > I have written a threaded tree control which is displayed in an
    > > applet.
    > > The way it works is that the reusable control is a canvas.
    > > The control is created in an applet and the canvas is drawn onto a
    > > panel.
    > >
    > > Things work great when the content is static, however when the tree
    > > structure
    > > is changed - i.e. someone adds a folder or deletes a file problems
    > > creep in.
    > >
    > > I have no problem updating the tree (which is the canvas) but after
    > > every change the new canvas needs to be placed on the panel.
    > >
    > > I have tried
    > >
    > > Panel.remove(tree);
    > > Panel.add("Center", tree);
    > > (there are three panels in total - the other two have scrollbars in
    > > them)

    >
    > In your description you wrote that "the new canvas needs to be placed
    > on the panel", but in the code snippet you add the same component
    > (named tree) instead of removing the existing component and adding a
    > new one. Do you have a "new canvas" or not?
    >
    > > But this does not appear to update when changes are made.

    >
    > There is no update because nothing has changed about the components that
    > would cause and update. If the contents of the component has changed,
    > but it size has not changed, invoke repaint on the component.
    >
    > > So I have tried
    > >
    > > Panel.removeAll();
    > > Panel.add("Center", tree);
    > > Panel.add("South", horizontalScrollbar);
    > > Panel.add("East", verticalScrollbar);
    > >
    > > This does the update perfect however I get a flickerwhen the update
    > > occurs.

    >
    > If it updates perfectly, chances are there is code outside of this
    > snippet that is causing the update.
    >
    > > So basically my question is in two parts?
    > >
    > > Can anyone suggest how I can update the panel to avoid it flickering?

    >
    > Go to you favorite Internet search engine and search for the terms
    > "double bufferring", "java", and "awt".
     
    lltaylor, May 7, 2004
    #4
  5. On 7 May 2004 02:25:26 -0700, lltaylor wrote:

    > OK, the way the code works which I didn't make apparent.

    (snip more vague descriptions)

    You will find that vague descriptions, top-posted..
    <http://www.physci.org/codes/javafaq.jsp#netiquette>
    ...to 100 line (non trimmed) replies (4th and 5th paragraph)..
    <http://www.physci.org/codes/javafaq.jsp#netiquette>
    ...are less effective at explaining than, say..
    <http://www.physci.org/codes/sscce.jsp>
    as I mentioned..
    <http://google.com/groups?th=3ee994846e9c1d10#link2>

    You might be getting better answers at..
    <http://www.physci.org/codes/javafaq.jsp#cljh>

    HTH

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, May 7, 2004
    #5
  6. lltaylor

    lltaylor Guest

    Andrew, Get over yourself.

    I don't see the point in replying if all it is about is to boast
    how great you are, and that you have a web site - wow.


    Andrew Thompson <> wrote in message news:<ynl3w6xj81vh$.m56zuz1awo0e$>...
    > On 7 May 2004 02:25:26 -0700, lltaylor wrote:
    >
    > > OK, the way the code works which I didn't make apparent.

    > (snip more vague descriptions)
    >
    > You will find that vague descriptions, top-posted..
    > <http://www.physci.org/codes/javafaq.jsp#netiquette>
    > ..to 100 line (non trimmed) replies (4th and 5th paragraph)..
    > <http://www.physci.org/codes/javafaq.jsp#netiquette>
    > ..are less effective at explaining than, say..
    > <http://www.physci.org/codes/sscce.jsp>
    > as I mentioned..
    > <http://google.com/groups?th=3ee994846e9c1d10#link2>
    >
    > You might be getting better answers at..
    > <http://www.physci.org/codes/javafaq.jsp#cljh>
    >
    > HTH
     
    lltaylor, May 7, 2004
    #6
  7. On 7 May 2004 07:04:59 -0700, lltaylor wrote:

    > I don't see the point in replying if all it is about is to boast
    > how great you are,


    I don't see the point in replying at all if
    you do not attentively read the responses
    you receive, and formulate reasoned responses.

    >..and that you have a web site - wow.


    ...and you have broken code - wow.

    F'Ups set to c.l.j.help.

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, May 7, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Love

    applet vs. canvas in applet

    Rob Love, Jul 7, 2003, in forum: Java
    Replies:
    1
    Views:
    622
    Liu, Chunyen
    Jul 7, 2003
  2. Askari
    Replies:
    2
    Views:
    713
    Askari
    Aug 30, 2004
  3. PhilC
    Replies:
    2
    Views:
    895
    PhilC
    Oct 25, 2004
  4. Lew

    Re: Applet ( canvas )

    Lew, Mar 13, 2009, in forum: Java
    Replies:
    2
    Views:
    420
    Andrew Thompson
    Mar 20, 2009
  5. Replies:
    10
    Views:
    267
    Rick Johnson
    Mar 15, 2013
Loading...

Share This Page