有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

HTML表格边框的java Swing呈现

javax.swing.text.html.CSS的JavaDoc来看,它只提供有限的CSS支持。边界已建模但未渲染

如何扩展类以提供边界渲染,最佳起点在哪里


共 (1) 个答案

  1. # 1 楼答案

    Java的CSS呈现当然支持边框。例如

    Swing controls with HTML border

    import java.awt.*;
    import javax.swing.*;
    
    class SwingHTMLBorder {
    
        static String html = "<html>" +
            "<head>" +
            "<style type='text/css'>" +
            "p {" +
            "   border: solid 1px red;" +
            "}" +
            "</style>" +
            "</head>" +
            "<body>" +
            "<p>Do you see a border?</p>" +
            "<table border=1>" +
            "<tr>" +
            "<td>Cell 1</td>" +
            "<td>Cell 2</td>" +
            "</tr>" +
            "</table>";
    
        public static void main(String[] args) {
            Runnable r = new Runnable() {
                @Override
                public void run() {
                    JOptionPane.showMessageDialog(null, new JLabel(html));
                }
            };
            // Swing GUIs should be created and updated on the EDT
            // http://docs.oracle.com/javase/tutorial/uiswing/concurrency
            SwingUtilities.invokeLater(r);
        }
    }