开发者

How can you get information from a running applet?

I'm running a little开发者_如何学C applet game in the appletviewer, and I have another java program that periodically tries to get the 'score' field from the applet.

However right now the way I'm trying to do this is (slightly pseudocode-ified):

Applet myGame = Game();

Runtime.exec("appletviewer Game");

score = myGame.getCurrentScore;

The problem is that the applet variable that I initialize doesn't correspond to the Applet created by the appletviewer. How can I resolve this?


You wouldn't be able to do that. A few options:

  1. Write your information out to a file periodically to be read in by your secondary process.
  2. Write your information to a database to be read by your secondary process.
  3. Rearchitect your game to be called entirely from your secondary process so it has access to its memory. (So instead of using exec, be like myGame.startGame().)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜