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 9221593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:36:42+00:00 2026-06-18T03:36:42+00:00

Here is the ‘protocol syntax’ I am using to add messages of type (general),

  • 0

Here is the ‘protocol syntax’ I am using to add messages of type (general), (whisper), (guild), or (global)

// add the message in list box
ChatJInternalFrame.modelChatList.addElement("(general)" + characterName + ": " + chatMessage);

Here is where I setup my list’s model and cell renderer:

modelChatList = new DefaultListModel<String>();
listForChat = new JList<String>(modelChatList);
listForChat.setFont(new Font("Lucida Console", Font.PLAIN, 14));
listForChat.setCellRenderer(new ColoredChatListRenderer());

And here is my custom cellRenderer:

public class ColoredChatListRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);  

        String s = String.valueOf(value);
        String splitPipe[] = s.split("\\)");        

        if(s.length() > 7 && s.substring(0, 8).equals("~SERVER~")){
            setForeground(Color.red);
        } else if (splitPipe[1].length() > 11 && (splitPipe[1].substring(0,12).equals("DEV Proskier") || splitPipe[1].substring(0,11).equals("DEV Sparkle"))){
            setForeground(Color.orange);
        } else {
            if (splitPipe[0].equals("(general")){
                setForeground(Color.black);
            } else if (splitPipe[0].equals("(whisper")){
                setForeground(Color.magenta);
            } else if (splitPipe[0].equals("(guild")){
                setForeground(Color.blue);
            } else if (splitPipe[0].equals("(global")){
                setForeground(Color.pink);
            }
        }
        return(this);
    }
}

chat modes

Right now this works perfectly, however I think I don’t want the type (general), (whisper), etc showing up in the chat, just the color change. Sorry if this is a real easy question, my brain hurts from working on the chat window with focus traversal crap I used to switch chat modes.

Is there some easy way to do this???
like just substring chopping off the first few chars, I can make the modes same length… aka (GEN), (GLO), (GUI), (WHI)

****EDIT****

I appreciate the help but this was the simplest solution for me. Please let me know if this is bad in some way.

    if (splitPipe[0].equals("(general")){
        setText(splitPipe[1]);
        setForeground(Color.black);
    } else if (splitPipe[0].equals("(whisper")){
        setText(splitPipe[1]);
        setForeground(Color.magenta);
    } else if (splitPipe[0].equals("(guild")){
        setText(splitPipe[1]);
        setForeground(Color.blue);
    } else if (splitPipe[0].equals("(global")){
        setText(splitPipe[1]);
        setForeground(Color.pink);
    }
  • 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-18T03:36:43+00:00Added an answer on June 18, 2026 at 3:36 am

    Create a custom Object that contains two pieces of data, the type of message and the text of the message. Add the object to the ListModel. Then your renderer can check the type for highlighting purposes and use the text for display purposes.

    See: Java: Swing JComboBox, is it possible to have hidden data for each item in the list? for an example of this approach. The example uses a combobox but the concept is the same.

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

Sidebar

Related Questions

Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
here's a conundrum for you, Using Django 1.4, I cannot get messages set through
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is what I am getting when I use single line comment (using --
Here is the syntax I am trying to use to replace PHP5.3 problematic if
Here's my jQuery script: $.ajax({ type: 'POST', url: 'zipCodes.php', data: searchZipCode, cache: false, success:
here is what I want to do: Add a CALayer as a sublayer to
Here is my problem: I have a chatapplication and the messages are displayed in
Here is my problem.. I have the option to create(add) two new input fields,

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.