I don't remember who asked the question, but I think the missing piece
of the puzzle is that he's writing into the status bar--it's not the
same as writing into the contentpane.
Try this:
1. Make the String msg into a class variable so you can create the
string in one method and access it in another.
2. Override the applet's "paint" method by adding this:
public void paint( Graphics g ) {
super.paint(g);
showStatus( msg );
}
3. Remove showStatus call from generateQuestion method and replace
with repaint();
I think that's all I did to make it work (starting from your original
code). If I forgot something, let me know.
John
Andrew M. Hoerter wrote:
> On Sat, 1 Nov 2003, Russ Wright wrote:
>
>
>>Okay I created the public void start() function and moved the code that
>>generates the statusbar message to there. I still don't see the message.
>
>
> Well, it doesn't work here either, and I'm not sure why to tell you the
> truth. It doesn't seem like there should be any dependencies between
> showStatus() and stuff you left in init(). I'm sure there is a Java guru
> here who can explain.
>
> But, it does work when you don't override init() and simply do everything
> in start(), as I suggested. This kind of thing is really not what init()
> is intended for, anyway. You could almost think of it as a constructor,
> and then start() and stop() act as an on/off switch once the applet is
> loaded (you'd probably want to repaint your GUI items in this case, I
> would think, which presumably doesn't happen if that stuff is in init()).
>
> As should be obvious, I'm not a Java expert by any means!
>
> -----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.
>
>
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:37:20 EDT