Java JScrollBar Design

I guess you are looking for a transparent scrollbar. This is just presented as an idea(NOT tested code): import java.awt.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.basic.*; public class TranslucentScrollBarTest { public JComponent makeUI() { JTextArea cmp = new JTextArea(); String str = “1234567890abcdefghijklmnopqrstuvwxyz”; for(int i=0; i<20; i++) { cmp.append(str+str+”\n”); } cmp.setForeground(Color.WHITE); cmp.setBackground(Color.BLACK); cmp.setOpaque(true); JScrollPane scrollPane … Read more

JEditorPane with Javascript and CSS support

+1 to mKorbel. Use JavaFX WebView which supports HTML5 by integrating it with Swing. Here is an example: import java.awt.*; import java.awt.event.*; import java.net.MalformedURLException; import java.net.URL; import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import static javafx.concurrent.Worker.State.FAILED; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.web.WebEngine; import javafx.scene.web.WebEvent; import javafx.scene.web.WebView; import javax.swing.*; public class SimpleSwingBrowser implements Runnable { … Read more

Highlight a word in JEditorPane

Basically, you should be able to walk the document looking for the match(es) you need… public class TestEditorPane01 { public static void main(String[] args) { new TestEditorPane01(); } public TestEditorPane01() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } JEditorPane … Read more

JEditorPane with inline image

You need to add a protocol handler for “data:” so an URL/URLConnection can be opened for it. Alternatively you could create some protocol handler “resource:” for class path resources. You need a package data with a class Handler (fixed name convention!). This will be the factory class for “data:” return an URLConnection. We will create … Read more

Is it possible/how to embed and access HTML Files in a JAR?

File manual = new File(getClass().getResource(“/manual/help.html”).toURI()); That is where it goes wrong. Java cannot create a File object from an embedded-resource Keep it as an URL and use that for setPage(..). As to the more general problem. HTML from a Jar file that links resources (e.g. CSS or images) by relative references will work just fine. … Read more

Inconsistent performance applying ForegroundActions in a JEditorPane when reading HTML

Using the sscce below, I am unable to reproduce the effect you describe. Such anomalies may arise if Swing GUI objects are not constructed and manipulated only on the event dispatch thread. The example uses EventQueue.invokeLater() accordingly. import java.awt.BorderLayout; import java.awt.Color; import java.awt.EventQueue; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JToolBar; import javax.swing.text.StyledEditorKit; import javax.swing.text.html.HTMLEditorKit; /** http://stackoverflow.com/questions/8523445 … Read more