Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1028143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:20:32+00:00 2026-05-16T12:20:32+00:00

OK so I have this HashMap private Map<String, Player> players = new HashMap<String, Player>();

  • 0

OK so I have this HashMap

private Map<String, Player> players = new HashMap<String, Player>();

Here is what I use to remove:

      public void destroy() {

players.remove("Red");
os.println(me.getUsername() + "|1|has left|yes|chat");

      }

I say Red because it’s just a TEST right now. I will get the eventual correct one later. Anyways…

I use THIS to check.

  if (e.getKeyCode() == KeyEvent.VK_Q) {
            for (Player playert : players.values()) {
                                        c.append("\n < "+playert.getUsername() + " > ");
                        }
                    }

When I’m all by myself.. I press Q and I get:

< Dan >

then my friend Red logs in and I Press Q… I get:

< Dan >
< Red >

then he leaves I press Q and I get:

< Dan >
< Red >

So.. how come this isn’t working?

Also, here is the code that gets called in init() when a player logs in the game (starts the applet)

 public void playerLogin() throws IOException {

            Random roll = new Random();
            int newNo = roll.nextInt(200);
            // me.getUsername() = "Guest #" + roll.nextInt(110);
            // String me.getUsername() = getParameter("name");

            me = new Player();
            me.setUsername(getParameter("name"));
            me.setPlayerImage(ImageIO.read(getClass().getResource("me.gif")));
            me.setX(256);
            me.setY(256);
            me.setMap(1);
            me.setCommand("move");
            players.put(me.getUsername(), me);

            repaint();

            System.out.println(me.getUsername() + " was added. player: " + me);
            os.println(me.getUsername() + "|" + me.getX() + "|" + me.getY() + "|"
                        + me.getMap() + "|" + me.getCommand());

            attack = 4;
            defense = 5;
            gold = 542;
            level = 1;
            exp = 53;

      }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:20:33+00:00Added an answer on May 16, 2026 at 12:20 pm

    In other words, your Applet#destroy() method is not called at the moment you expect it is called? You should use Applet#stop(). The destroy() is only called when the object in question is eligible for GC and/or when the whole browser instance is been closed (and thus not only the current page/tab). JVM may namely keep running as long as the browser instance runs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK so this is a BIT different. I have a new HashMap private Map<String,
I have a Hashmap in Java like this: private Map<String, Integer> team1 = new
I have for instance this Map: Map<String, Integer> map = new HashMap<String,Integer>(); than I
I have this class: public class docInfo { private int freq; private HashMap<String, Double>
I have a property @JsonProperty private Map<String, String> parameters = new HashMap<String, String>(); When
I have an ArrayList of HashMap like this: ArrayList<HashMap<String, String>> playListSongs = new ArrayList<HashMap<String,
Guys, this is silly, but i got to ask You have a private Map<String,
I have declared the following method: private void mockInvokeDBHandler(Map<String, Object>... rows) { List<Map<String, Object>>
If I have a HashMap that looks like this: HashMap<String, MyObject> where the String
I currently have a variable that looks like this: val someVal = new HashMap[Float,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.