Applet Canvas / Panel Problem

L

lltaylor

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
 
A

Andrew Thompson

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

I have tried...
So I have tried
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>
 
A

A. Bolmarcich

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".
 
L

lltaylor

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
 
A

Andrew Thompson

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
 
L

lltaylor

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.
 
A

Andrew Thompson

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top