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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:02:57+00:00 2026-06-08T11:02:57+00:00

This is the code I have in a file called Test2.java in a package

  • 0

This is the code I have in a file called Test2.java in a package called test2 in a project called Test2;

package test2;

import javax.swing.JFrame;

public class Test2 {
    public static void main(String[] args) {
    JFrame mainWindow = new HtmlWindow("<html>"
            + "<a href=\"http://stackoverflow.com\">"
            + "blah</a></html>");
        mainWindow.setVisible(true);
    }
}

In the same package I have this code in a file called HtmlWindow.java ;

package test2;

import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JLabel;


class HtmlWindow extends JFrame {
    public HtmlWindow(String refreshGrid) {
        super("blah");
        setSize(300, 100);
        Container content = getContentPane();
        String labelText = refreshGrid;
        JLabel coloredLabel = new JLabel (labelText, JLabel.CENTER); 
        content.add(coloredLabel, BorderLayout.NORTH);

    }

}

When I run the project, I get a window with the word “blah” in the expected location, blue and underlined, but the cursor does not change when I hover over the word, nor does anything happen when I click on it.

My questions are as follows;

  • Is it possible to put hyperlinks in jLabels?
  • If so, am I doing something wrong, or is the programme not running properly?
  • If not, what is a good alternative? The reason I am not using JButtons, is that eventually I want to create a grid of an arbitrary number of hyperlinks, and I want the hyperlinks to be images, and whilst JButtons can have images on them, I don’t want the hyperlinks to look like “buttons”. I suppose I could use a non-editable JEditorPane?
  • 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-08T11:02:59+00:00Added an answer on June 8, 2026 at 11:02 am

    Swing is not a fully functioned browser. It supports simple HTML including links but do not change the cursor style automatically. As far as I know you have to do it programmatically, i.e. add mouse listener to your label and change the cursor style when your mouse is over your label. Obviously you can write your own class LinkLabel that implements this logic and then use it every time you need.

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

Sidebar

Related Questions

I have the following code in a file called Test2.java in a package called
I'm trying to work this out. In my project, i have a file called
I have this code in a xaml file now in a event handler code
I have this code to download a file, but on sourceforge.net sever there is
I have this code to move my uploaded file to a specific directory: if
I have this code that reads from XML file. It gets five strings (groupId,
I have a xaml file with this code: <GridViewColumn x:Name=lvCol3 Header=Quantità Width=120> <GridViewColumn.CellTemplate> <DataTemplate>
I have this code to write to a file, it works perfect but I
I have this code which will include template.php file from inside each of these
I have this code that saves a pdf file. FileStream fs = new FileStream(SaveLocation,

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.