use of javax.swing.text.html.HTMLEditorKit in project OpenAM by OpenRock.
the class TableJPanel method appendMessage.
private void appendMessage(String colorString, String s) {
HTMLEditorKit kit = (HTMLEditorKit) messagejEditorPane.getEditorKit();
HTMLDocument doc = (HTMLDocument) messagejEditorPane.getDocument();
try {
String newS = s.replaceAll("<", "<");
newS = newS.replaceAll(">", ">");
newS = newS.replaceAll("\n", "<br>");
kit.insertHTML(doc, messagejEditorPane.getCaretPosition(), "<font color=" + colorString + ">" + newS, 0, 0, HTML.Tag.FONT);
messagejEditorPane.setCaretPosition(doc.getLength() - 1);
} catch (Exception ex) {
//ex.printStackTrace();
System.out.println("Exception in TableJPanel :" + ex.getMessage());
}
}
use of javax.swing.text.html.HTMLEditorKit in project intellij-community by JetBrains.
the class StudySwingToolWindow method createTaskInfoPanel.
@Override
public JComponent createTaskInfoPanel(Project project) {
myTaskTextPane = new JTextPane();
final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane);
myTaskTextPane.setContentType(new HTMLEditorKit().getContentType());
final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
int fontSize = editorColorsScheme.getEditorFontSize();
final String fontName = editorColorsScheme.getEditorFontName();
final Font font = new Font(fontName, Font.PLAIN, fontSize);
String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }" + "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:" + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" + "code {font-family: Courier; display: flex; float: left; background-color:" + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}";
((HTMLDocument) myTaskTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
myTaskTextPane.setEditable(false);
if (!UIUtil.isUnderDarcula()) {
myTaskTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
}
myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10));
myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
return scrollPane;
}
use of javax.swing.text.html.HTMLEditorKit in project jdk8u_jdk by JetBrains.
the class LargeQuickDoc method main.
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> {
JFrame f = new JFrame();
JEditorPane editorPane = new javax.swing.JEditorPane("text/html", "");
editorPane.setEditorKit(new HTMLEditorKit());
editorPane.setEditable(false);
JScrollPane scrollPane = new JScrollPane(editorPane);
scrollPane.setBorder(null);
try {
editorPane.setText(getText());
} catch (IOException | ArrayIndexOutOfBoundsException e) {
throw new RuntimeException(e);
}
f.getContentPane().add(scrollPane);
f.setSize(500, 500);
f.setVisible(true);
});
}
use of javax.swing.text.html.HTMLEditorKit in project jdk8u_jdk by JetBrains.
the class bug8058120 method createAndShowGUI.
private static void createAndShowGUI() {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception ex) {
throw new RuntimeException(ex);
}
JFrame frame = new JFrame("bug8058120");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setEditorKit(new HTMLEditorKit());
document = (HTMLDocument) editorPane.getDocument();
editorPane.setText(text);
frame.add(editorPane);
frame.setSize(200, 200);
frame.setVisible(true);
}
use of javax.swing.text.html.HTMLEditorKit in project jdk8u_jdk by JetBrains.
the class bug8028616 method main.
public static void main(String[] args) throws Exception {
ParserCB cb = new ParserCB();
HTMLEditorKit htmlKit = new HTMLEditorKit();
HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
htmlDoc.getParser().parse(new StringReader(text), cb, true);
synchronized (lock) {
if (!isCallbackInvoked) {
lock.wait(5000);
}
}
if (!isCallbackInvoked) {
throw new RuntimeException("Test Failed: ParserCallback.handleText() is not invoked for text - " + text);
}
if (exception != null) {
throw exception;
}
}
Aggregations