Using Java Swing to apply HTML styling to text strokes

I have come across this code snippet for a Java swing JLabel:

"<html>\n" +
"<head><style>\n" +
"p {    color: white;\n" +
"    text-shadow:\n" +
"    -1px -1px 0 #000,\n" +
"    1px -1px 0 #000,\n" +
"    -1px 1px 0 #000,\n" +
"    1px 1px 0 #000; }" +
"</style></head>\n" +
"<body><p>testing123</p></body>\n" +
"</html>"

This is a customized example I discovered on how to add an outline around text using HTML. Although the text "testing123" appears in white (or any specified color), the shadow or outline doesn't show up irrespective of the background color. This method works on the w3schools css tester page, but it seems that it's not compatible with all browsers, including swing. Is there a way to implement this successfully?

Answer №1

I recently discovered that this feature only functions on specific browsers, meaning swing is not included, right?

Your assumption is correct! Swing's compatibility with HTML is limited to a subset of HTML 3.2 and its CSS support is inconsistent.

Is there a solution to make this work?

The most effective solution would be utilizing the Java-FX based WebView. This allows Java-FX components to be integrated into Swing applications seamlessly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Resizing an image that is being pulled from a database

I am currently working on a challenging database project that seems to have hit a minor cosmetic roadblock. The database I'm dealing with loads profiles into arrays for display using a PHP while loop, making it easy to display content and allow for a ...

Creating a responsive HTML table in R can be achieved by using the 'DT

Below is the structured dataframe I am working with in R: Dataframe- seq count percentage Marking count Percentage batch_no count Percentage FRD 1 12.50% S1 2 25.00% 6 1 12 ...

Designing a dropdown menu with sub-menus that appear when hovered over

In my quest to design CSS that will dynamically display links in left-to-right divs, I am seeking a way for sub-menus to appear below the menu being rolled over. The challenge lies in the fact that these menus will be loaded from a WordPress database, mean ...

Modifying Table Cell Background Color in ReactJS: A Guide to Conditionally Updating Cell Color Without Affecting the Entire Row

I am working on changing the background color of a cell based on its value. Currently, I am utilizing the following library: react-data-table-component Procedure: If the value is above 0, then the cell's background color will be red. Otherwise, th ...

"Having the same meaning as $(this) in jQuery, the CSS

Is there a CSS equivalent to the Jquery selector $(this)? For example: .widget h4 { background: black } .widget:hover h4 { background: white } In this scenario, when any element with the .widget class is hovered over, the child h4 changes its background ...

Jackson encountered an issue deserializing an instance of java.util.ArrayList from a VALUE_STRING token

I'm facing a challenge deserializing a JSON string. Despite trying various methods, I seem to be stuck at this point in my code. Maven dependencies: <dependency> <groupId>org.glassfish.jersey.core</groupId> <a ...

How can we style the <a> link once it has been downloaded?

Is there a way to change the color of a download link after it has been clicked on? I've attempted using the visited attribute, but it only seems to work with regular links and not with download documents: Appreciate any help ...

The CSS overflow property does not seem to be functioning properly when applied to a span element that

Here is my current setup: http://jsfiddle.net/YKXUb/1/ My CSS looks like this: .two { height: 100%; width: 100%; border:1px solid green; } .hold { float: left; height: 100%; width: 35%; border:1px solid green; } .right { hei ...

Using jQuery .animate() leading to erratic input movements

I am currently utilizing jQuery's .animate() feature to create a smooth animation effect on the width of a <div> element when a child <input> is in focus. Nevertheless, I'm encountering an issue where the input field jumps up and down ...

Error message retrieval in Liferay fails due to malfunctioning Ajax listener

While working on a project using liferay jsf, I encountered an issue with inserting <f:ajax listener="#{jsfController.searchValidDestination}"> within <h:selectOneMenu/> in my view page. The problem is that I am not getting any result from the ...

Discovering whether a link has been clicked on in a Gmail email can be done by following these steps

I am currently creating an email for a marketing campaign. In this email, there will be a button for users to "save the date" of the upcoming event. I would like to implement a feature that can detect if the email was opened in Gmail after the button is cl ...

How to integrate a chips feature in Angular 4 using Typescript

Struggling to incorporate a chips component into my Angular web application, which comprises Typescript, HTML, and CSS files. After grappling with this for weeks without success, I have yet to find the right solution. To review my current code, you can a ...

best practice for parsing JSON strings in Java

I have a JSON string/response that I need to parse in a simple way to extract objects/arrays. The structure may be complex and repeated, so I need to retrieve the data list by list. Most parsers only work with basic JSON structures, but mine is a bit mor ...

Combining CSS and JS files for accordion list - experiencing issues when used separately

Recently, I've been trying to create an accordion list and stumbled upon some code (HTML, CSS, and JS) on www.w3schools.com. When I have the code all in one document and run it as a single .html file, everything works perfectly. However, when I split ...

The window fails to retain the scroll position when overflow is enabled

Whenever I click on a specific div, I use jQuery to dynamically apply overflow: hidden to the html and body. $(".mydiv").on("click", function() { $("html, body").css("overflow", "hidden"); }); However, this action causes the window to scroll to the to ...

ChakraUI failing to display on the screen

Exploring Chakra UI in my latest project has been an exciting journey for me. I made sure to install all the necessary dependencies and started importing components from the ChakraUI Docs. Initially, I successfully imported and rendered the button feature ...

Strategies for effectively confirming word boundaries in unprocessed text during document preprocessing

After conducting extensive research, I have come across matches that relate closely to word boundaries in sentences or suggest the use of tokenizers. However, this is not exactly what I am searching for. My query can be summarized as follows: Currently, I ...

Tips for aligning elements vertically within a <td> tag

I am looking to vertically align 3 elements within my <td> tag, specifically in the center/middle. These are the elements I want to align: An image button (a tag) with a top arrow image A jQuery slider Another image button (a tag) with a bottom arr ...

Tips for setting background colors as a prop for Material UI cards in React JS

Currently utilizing the Material UI next framework to construct a wrapper for the card component. This customized wrapper allows for personalization of the component. I have successfully extended the component so that the title and image within the card ca ...

Tips on transforming json data into nested Maps with Gson

I have a custom Java class MyModel.java: public class MyModel { String name; int age; Details details; } In Details.java I have: public class Details { Info info1; Info info2; } In Info1.java and Info2.java, both have a common field called data ...