|
Post by JuanMa on Aug 3, 2015 11:54:23 GMT -8
Ok,
I also re-read our last mail and realized that you already answered my question and is related to Patreon support.
|
|
|
Post by chriscrawford on Aug 4, 2015 10:38:39 GMT -8
Here's today's problem: the drawing process does not erase previous imagery. That is, it simply draws over the previous image. Here's what I mean (this image will go away in a month or so): The latest sentence "I request deal Zubi period" is drawn over the previous sentence. Or, to put it more precisely, the previous sentence was not erased. Normally, I would just re-draw the background (in this case, the bluish bubble) before drawing the new sentence, but that can't work here because this is a JLayeredPane, which means that the bubble is ALWAYS drawn behind the text. Anything that I draw that will erase the old text must be on a higher layer than that text, which means that it will ALSO be on a higher level than the new text. The problem appears to be insoluble: anything that can erase the old text will necessarily erase the new text. From a procedural point of view, this is ridiculous: you simply draw an erasing background, and then draw the new text. But Java isn't procedural; an image is a stationary object. The program gives orders to change the stationary image, then at some point in the future that stationary image will be drawn -- but the program doesn't know when. It is possible, of course, to have the program draw the stationary image, then wait long enough to be sure that the image has been drawn, then issue a new drawing. But that's a hack of the ugliest degree. The problem appears to be intrinsic to the JLayeredPane. It would not arise with any other JComponent. So, do I abandon layered panes, or do I fight JLayeredPane? As always, programming in Java involves a lot of hand-to-hand combat with the language.
|
|
|
Post by ldargin on Aug 4, 2015 14:53:20 GMT -8
Do you call revalidate() to refresh the pane?
|
|
|
Post by chriscrawford on Aug 4, 2015 15:45:44 GMT -8
I found it. The routine that draws everything starts off with these two statements:
if (rightPanel.getComponentCount()>0) rightPanel.remove(0);
Looks pretty conventional, right? Just clearing out the component, right? Ah, but it should be:
while (rightPanel.getComponentCount()>0) rightPanel.remove(0);
The difference between the two is that the original code removes the zeroth component from the component list. The corrected version removes ALL the components from the component list. And that's what permits the code to redraw the image correctly.
On to the next windmill...
|
|
|
Post by chriscrawford on Aug 4, 2015 16:48:28 GMT -8
Well, that was easy: I suppose that now I must begin the really big jump from the text interface to the icon interface. This one is going to be much harder.
|
|
|
Post by chriscrawford on Aug 9, 2015 7:32:44 GMT -8
I have decided to proceed with the demolition and reconstruction of the program. This will be bloody. To work!
|
|