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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:35:59+00:00 2026-05-26T17:35:59+00:00

I am creating a Help System that uses links (a JButton extension) that expand

  • 0

I am creating a Help System that uses links (a JButton extension) that expand and collapse subpanels with JLabels in them. The links and the collapsible panels work, but I’m having trouble implementing my find dialog. I want to be able to highlight parts of the text for which the user searches. I think my use of text attributes to underline the text in the links is messing with my ability to highlight the parts of the text, but I’m not sure how to do it differently. Here’s the code for my Link class which my links subclass:

public abstract class Link extends JButton {

private static final int SPACE = 5;

private static final Color TEXT_COLOR = Color.BLUE;

public Link(String text) {
    super(text);

    setBorder(BorderFactory.createEmptyBorder(SPACE, SPACE, SPACE,
            2 * SPACE));
    setContentAreaFilled(false);
    setFocusable(false);
    setForeground(TEXT_COLOR);

    Map<TextAttribute, Integer> underlineAttribute =
        new HashMap<TextAttribute, Integer>();
    underlineAttribute.put(TextAttribute.UNDERLINE,
            TextAttribute.UNDERLINE_ON);
    setFont(getFont().deriveFont(underlineAttribute));
}

}

How can I implement highlighting text in my links without getting rid of the underlining? Do I need to change them to subclass something else?

  • 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-26T17:36:00+00:00Added an answer on May 26, 2026 at 5:36 pm

    One approach is to use HTML formatting for the button text. Of course, the path of least surprise for the end user would be if the buttons looked like buttons and the links looked like links (i.e. not buttons).


    Should I subclass something else for the links?

    For a link I’d generally use a JTextField, as shown on my answer to How to change JButton?

    E.G.

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

Sidebar

Related Questions

Ok need some help, I have a system I'm creating that will allow users
I could use some help creating an XSL template that will take a string
I'm looking for a file utilities library that help creating paths, i.e. if I
I need help with creating a C# method that returns the index of the
I am looking for some help on creating a regular expression that would work
I'm creating a system in VB.net that utilizes Lua via the LuaInterface. To associate
I am creating a web app that requires a live notification system. How would
I need a little help creating a catch-all error handling page in my ICEfaces
Is there a free software for creating windows help files for your program? I
I'm new to SQL and could use some help in creating a database schema

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.