开发者

How can you get information from a running applet?

开发者 https://www.devze.com 2023-03-31 09:29 出处:网络
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.

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

精彩评论

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