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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:53:39+00:00 2026-05-23T15:53:39+00:00

When I select a piece of text in a JTextArea, it gets coloured in

  • 0

When I select a piece of text in a JTextArea, it gets coloured in white and highlighted in blue (I’m using Nimbus LookAndFeel).

I changed it so the highlight is white, and the text also remains in black, so it is not noticed. What I want now is to get the text in bold when the user highlights it.

Is there any easy way to do this? Would it work if I create a listener for double-click, or would the text get bold but not highlighted at all?

  • 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-23T15:53:40+00:00Added an answer on May 23, 2026 at 3:53 pm

    See DefaultHighlighter source
    Inner class DefaultHighlightPainter has method

    public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c)
    

    You can specify font there. Just call setFont() for the Graphics instance.

    NOTE: bold font could have different widht so you should use font like “Monospaced”

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

Sidebar

Related Questions

Select only showing first character of option text in IE 9 Using click on
i want to select the next piece of text which is underlined. You see
I have the following piece of SQL: select DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) which comes through as
This is a piece of UI code <select id=order_unit_line_rate_806782_is_addenda_enabled class=selects_for_487886 onchange=select_addendum(806782, this);dateShowMemory(this.options[this.selectedIndex].value, '806782'); uniqueattr=Dynamic
Why isn't the following piece of code working in IE8? <select> <option onclick=javascript: alert('test');>5</option>
How do i select the preceding nodes of a text node starting from a
I am trying to select the text from a text box and pass it
I'm executing a SELECT query on a table in MySQL using the command-line interface
This piece of code grabs a customers hire record using their hire ID and
I've got a short piece of text, and I want to stretch it out

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.