gpt4 book ai didi

java - JEdi​​torPane 中呈现数学符号的问题

转载 作者:搜寻专家 更新时间:2023-11-01 03:51:50 25 4
gpt4 key购买 nike

我正在尝试在 JEditor 中呈现以下代码,它在 chrome 和 Mozile 浏览器中运行良好,但在 EditorPane 中运行不正常。

<html><body>In the given figure, ABCD is a quadrilateral 
in which BD = 10 cm, AL <SPAN>^</SPAN> BD,
CM <SPAN style=\"FONT-FAMILY:Symbol\">^</SPAN>
BD such that AL = 4 cm and CM = 6 cm.
Find the area of quadrilateral ABCD.<BR>
<IMG align=middle </body></html>

Relacing tags with Unicode 工作正常,但我想使用 Tags 显示它。

最佳答案

此代码可能会解决您的问题。

                // make it read-only
editorPane.setEditable(false);
// add an html editor kit
HTMLEditorKit htmlkit = new HTMLEditorKit();
HTMLDocument htmlDoc = (HTMLDocument) htmlkit.createDefaultDocument();
editorPane.setEditorKit(htmlkit);

String htmlString = "<html><body>In the given figure, ABCD is a quadrilateral in which BD = 10 cm, AL <SPAN>^</SPAN> BD, CM <SPAN style=\\\"FONT-FAMILY:Symbol\\\">^</SPAN> BD such that AL = 4 cm and CM = 6 cm. Find the area of quadrilateral ABCD.<BR><IMG align=middle </body></html>";
Reader htmlStringReader = new StringReader(htmlString);

try {
htmlkit.read(htmlStringReader, htmlDoc, 0);
} catch (IOException e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
e1.printStackTrace();
} catch (BadLocationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
editorPane.setEditorKit(htmlkit);
htmlDoc.putProperty("ZOOM_FACTOR", new Double(0.5));
editorPane.setDocument(htmlDoc);

最好的问候,佩德罗·阿扎姆。

关于java - JEdi​​torPane 中呈现数学符号的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24529471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com