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

  • SEARCH
  • Home
  • 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 8011653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:04:54+00:00 2026-06-04T19:04:54+00:00

I have created java chat with subscriber and publisher. I am trying to send

  • 0

I have created java chat with subscriber and publisher. I am trying to send private message to specific user when I send the message all users got it, I have tried to cancel from user to get the message while I am using “IF” but its not working any idea.

else if (tempM[2].equals(chat)) {
  //send message to every one
  if (userNameListErea.isSelectionEmpty()) {
    chatTextErea.append(tempM[0] + ": " + tempM[1] + "\n");
  // not send message to your self.
  } else if (userNameListErea.getSelectedValue().toString().equals(userName)) {
    chatTextErea.append("Can not sent private to your self \n");
  // if its not public and not to ypurself the its private 
  }else {
    chatTextErea.append(userNameListErea.getSelectedValue() + " send u private: " +
      tempM[1] + "\n");
  }
}

maybe I missing the right command for blocking user from view the message

  • 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-06-04T19:04:56+00:00Added an answer on June 4, 2026 at 7:04 pm

    As you are trying to use the exact smae mechanism for sending a message to everyone and to one sepecific user, you will not get the result you are looking for.

    You need to add the logic to see if the current user is the same as the one the message is sent to. Based on the exampe you posted, userName is the name of the sender, so you need to have a similar logic for the receiver:

    }else if (userNameListErea.getSelectedValue().toString().equals(currentUserName)) {   
      chatTextErea.append(userNameListErea.getSelectedValue() + " send u private: " +   
      tempM[1] + "\n");   
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a JAVA application. Sometimes, users do invalid operations on it or
I have created a Java Swing application. Some users can't connect to the internet
I have created a new AjaxLink in my .java file add(new AjaxLink(link){ private static
I have created java api -ported from C# to be more specific- which aside
I have created a Java webapplication containing a tobago sheet. I am now trying
I am trying to create a simple chat program using Java. I have create
I have created a Java web service and I am trying to access this
I have created a java application for Debian Linux. Now I want that that
I have created a java application and packed it into a jar file on
I have created a java server, which takes screenshots, resizes them, and sends them

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.