Calling paint on a component will repaint the component but I guess is badly placed.Try to use the update method to trigger components repaint, this way you should be more coherent with the Swing gfx pipeline.

Well, something similar. The code works if I call quitButton's repaint() method instead of paint(Graphics). Why this should be, I have no idea. If anyone cares to enlighten me, I would be most grateful.

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

Yes, that's where I got the idea of using repaint. But as far as I could see, it doesn't explain why this is what works. OTOH, maybe I just missed it skimming through and trying things one after another.

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

The way it doesn't work is that scenViewer is displayed, a nice gray rectangle, but with no list inside it. I display the raw list beside it as a test; that comes out fine - one blah, one bleh, both selectable. I've looked through the examples, and I cannot figure out what I am doing differently from what they do. I have no painting code this time, I leave everything to the builtin paint method, which evidently calls paintComponents just as it is supposed to. Why isn't the JScrollPane painting its contents?

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

Ah, doesn't that look lovely, now? Thank you. I'm not sure whether to feel stupid for not seeing that, or pleased because it works at last. :-/ About the one-step, I used that too at first, then changed it do see if it made a difference.

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

Aggh! That is, the code works if I put it in the constructor of my game-initialiser object. However, I would like for the list to pop up when the player presses the "New Game" button, which means I would like to have the list waiting in the wings, then update in the actionPerformed method. As far as I understand the thread issues, this is safe, right?

However, if I do things this way, I get that grey rectangle again, instead of the list within a viewer that I get if the code is in the constructor. I've tried putting the initialisation code in the constructor and just adding it in actionPerformed, like this:

This did have the side effect of suddenly blanking (making white) half my screen, but I was able to fix that in paint(). Could you explain to me why these apparently similar procedures give such different results? You've been very helpful so far.

To win one hundred victories, in one hundred battles, is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

Chances are that the container needed more info - a revalidate() call perhaps? What you can try is setting a break point in the parent containers paint method and then stepping through to see what is happening.

But I would add the scroll pane in the beginning and do a setVisible(false) on it to hide it. The setVisible(true) when your button is pressed.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org