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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:57:56+00:00 2026-05-30T16:57:56+00:00

So I have a socket connected and constantly reading from a server. I have

  • 0

So I have a socket connected and constantly reading from a server. I have no problem printing lines to the terminal as they arrive, but I’m struggling with Swing. I want to add each line to the display as it comes in, with certain pre-defined words highlighted. I looked at JEditPane, and the only way I could see would be setText(getText()+newText), which I looked at and thought it looked very wrong. I had a look at the Document classes, and none of them seems to have an obvious append method. Am I missing something obvious, or is there an easy way to do this with another component?

  • 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-30T16:57:57+00:00Added an answer on May 30, 2026 at 4:57 pm

    One way to address this would be to create a JTextPane with a DocumentListener that will do your necessary hightlight.
    Create your text as you get from server and call insertString on the text pane’s document. The insertString would work as append.

    Check the javadoc out.

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

Sidebar

Related Questions

Here's my problem: I have server A, running node.js and using socket.io for communicating
Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d,
I have to create an sample code that connect to a socket server, and
I have a tcp socket sending three lines like this out2.println(message1\n); out2.println(message2\n); out2.println(message3\n); and
I have an open socket to a remote terminal. Using the answer to Force
We create a socket. On one side of the socket we have a server
I have a class that encapsulates tcp socket communications with a server. For each
I have a program (written in C/C++) that behaves as a socket server. I'd
I have a BluetoothSocket that I am reading data from, using a separate Thread
I have been doing socket programming for many years, but I have never had

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.