jeditorpane

hyperlinks in JEditorPane in a JTable

走远了吗. 提交于 2019-12-04 16:25:27
I swear... i hope this is the last question I have to ask like this, but I'm about to go crazy. I've got a JTable using a custom TableCellRenderer which uses a JEditorPane to display html in the individual cells of the JTable. How do I process clicking on the links displayed in the JEditorPane? I know about HyperlinkListener but no mouse events get through the JTable to the EditorPane for any HyperlinkEvents to be processed. How do I process Hyperlinks in a JEditorPane within a JTable? The EditorPane isn't receiving any events because the component returned from the TableCellRenderer is only

How do I set both StrikeThrough and Underline styling options for text inside a JTextPane?

感情迁移 提交于 2019-12-03 21:27:53
问题 I have a JTextPane component and I am trying to style the text that will be typed by the user to be both underline and strikethrough at the same time. The relevant snippet of code that that should set the strikethrough attribute of the next typed character to true is this: JEditorPane editor = getEditor(e); if (editor != null) { StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet();

Text editor with syntax highlighting and line numbers?

那年仲夏 提交于 2019-12-03 13:36:12
问题 This is a bit challenging even probably for a team project, let alone for a one-man implementation, but I was trying to put together a simple yet elegant text editor with syntax highlighting, using a JEditorPane . I stumbled upon this which was discontinued and really hard for me to understand with all the lexer files and .lex stuff inside. I even found in some blog that this project was later taken on by some other team but even yet again discontinued. I don't need it to be too fancy, like

Text editor with syntax highlighting and line numbers?

半腔热情 提交于 2019-12-03 03:34:38
This is a bit challenging even probably for a team project, let alone for a one-man implementation, but I was trying to put together a simple yet elegant text editor with syntax highlighting, using a JEditorPane . I stumbled upon this which was discontinued and really hard for me to understand with all the lexer files and .lex stuff inside. I even found in some blog that this project was later taken on by some other team but even yet again discontinued. I don't need it to be too fancy, like having code folding and stuff (even though I am tempted to find out how to do this), but I need at least

JEditorPane and custom editor kit

非 Y 不嫁゛ 提交于 2019-12-02 03:05:55
I've a trivial question. I need to load an existing file into JEditorPane using custom editor kit. I've a editor kit, a file with some extension and I need to force the JEditorPane to recognize my file and use my editor kit. I've found only, that's possibile, but nowhere how. The kit is based on HTML and the file too. If file has the .html extension, it works, but when I rename the file to .xhtbm , it is opened as plain text. The content type is set to text/plain , but I'm unable to register my editor kit for this type, because there is already registered another editor kit for this content

JEditorPane Hyperlink swing html

混江龙づ霸主 提交于 2019-12-01 12:14:49
I'm having a difficult time getting the hyperlink to work in a JEditorPane. Could someone please tell me what I'm doing wrong here? I want to be able to click on the link and the browser to open to that page. Thanks in advance. :D bottomText.setText("<a href=\"http://www.yahoo.com\">Yahoo</a>"); bottomText.setEditable(false); bottomText.setOpaque(false); bottomText.setEditorKit(JEditorPane.createEditorKitForContentType("text/html")); bottomText.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if(e.getEventType() == HyperlinkEvent.EventType

Can't show HTML + SVG

▼魔方 西西 提交于 2019-12-01 07:54:05
I used to use JEditorPane , but it can only display HTML, cannot display SVG, and nested SVG HTML cannot complete display. Then I use JSVGCanvas , but it can only display SVG, cannot display HTML. Is there any way to solve this problem? Configure JEditorPane to use the JSVGCanvas canvas for SVG. To achieve that, you need a specialist HTMLEditorKit . Here is the HTLMEditorKit of Appleteer . package org.pscode.ui.applet.appleteer; import java.awt.Component; import java.awt.Dimension; // placeholder component import javax.swing.JButton; import javax.swing.text.html.HTML; import javax.swing.text

JScrollPane scrollbar jumps down on JEditorPane.setText()

痴心易碎 提交于 2019-12-01 07:39:32
问题 Every time (except first time) I set text in JEditorPane scrollbar jumps to the bottom of JEditorPane. Is there any way to avoid this? One way that I tried is to use setCaretPosition(0) after setText(). It works but it's not exactly what I need. Scrollbar jumps down and then jumps up. Is there a way to avoid any movement of scrollbar at settext()? My code: package test; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JScrollPane;

Can't show HTML + SVG

旧城冷巷雨未停 提交于 2019-12-01 04:32:34
问题 I used to use JEditorPane , but it can only display HTML, cannot display SVG, and nested SVG HTML cannot complete display. Then I use JSVGCanvas , but it can only display SVG, cannot display HTML. Is there any way to solve this problem? 回答1: Configure JEditorPane to use the JSVGCanvas canvas for SVG. To achieve that, you need a specialist HTMLEditorKit . Here is the HTLMEditorKit of Appleteer. package org.pscode.ui.applet.appleteer; import java.awt.Component; import java.awt.Dimension; //

Getting the visible text in a JEditorPane

霸气de小男生 提交于 2019-12-01 01:39:21
I have a JeditorPane in a JScrollPane. At certain points in the application, I would like to retrieve the text that is visible in the scrollPane (the text that is currently showing) and only this text. Is there a way to do this? Thank you, Elliott camickr You can use the viewport to get the view position and size. JViewport viewport = scrollPane.getViewport(); Point startPoint = viewport.getViewPosition(); Dimension size = viewport.getExtentSize(); Point endPoint = new Point(startPoint.x + size.width, startPoint.y + size.height); Once you know the start/end points of the viewport you can use: