javax.swing.text.html


1. Create an HTML Editor

import javax.swing.text.html.*;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class SwingHTMLEditor {
    public static void main(String[] args) {
        JEditorPane editor = new JEditorPane();
        editor.setContentType("text/html");
        editor.setText("<html><body><h1>Hello World</h1></body></html>");

        JFrame frame = new JFrame("HTML Editor");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.add(new JScrollPane(editor), "Center");
        frame.setVisible(true);
    }
}

2. Display HTML from a URL

3. Load HTML from a String

4. Parse HTML and Get DOM

5. Add CSS Styles to HTML

6. Style HTML with Inline CSS

7. Insert Images into HTML

8. Add Hyperlinks to HTML

9. Create a Simple HTML Viewer

10. Display HTML in a JTextArea

11. Convert HTML to Plain Text

12. Extract Text from HTML

13. Create a Custom HTML Editor

14. Create a Web Browser

15. Embed HTML in a Swing Application

16. Create an HTML-Based Image Viewer