jeditorpane

Force JEditorPane within JScrollPane to shrink + re-wrap

谁说我不能喝 提交于 2019-12-13 02:14:24
问题 Having an issue with a JScrollPane expanding its child JEditorPane just fine but forcing horizontal scroll bars when resizing it down again (instead of forcing the JEditorPane to recalculate wrapping). The basic flow of code is as follows: JFrame f = new JFrame(); JEditorPane jep = new JEditorPane(); JScrollPane jsp = new JScrollPane(jep); f.add(jsp); 回答1: It's a hack, but the best way I could find (without using ugly ScrollPaneManager s) was to implement a ComponentListener on the

Java Eclipse Jtable Cell / Column

拜拜、爱过 提交于 2019-12-12 19:24:37
问题 for Java Kepler Eclipse and Jtable, I am trying to make it so as when a specific table cell is selected, that cell will work as an editorPane; or have the whole column work as editorPane. When I click a cell on column COMMENTS it enlargens the row but I cant get it to work as an editorPane. My project is actualy very different but I wrote this mini one with the table so you can copy, paste and run it to see exactly what the problem is when you click on a COMMENTS cell. I tried to make the

Adding mouselistener to JLabel/JButton inserted in JTextPane

自作多情 提交于 2019-12-12 11:16:50
问题 I have a problem where when I try and add a mouselistener to a JLabel or JButton in a JTextPane I get the error "cannot be converted to Mouselistener by invocation conversion". I would prefer to have the component in a JEditorPane. I also heard a HyperlinkEvent could be used. Basicly I want a component that can be right/left clicked in a JEditorPane(preffered)/JTextPane. Any help would be appreciated Now it works (sortof) it only recives right clicks and I need to not draw button edges. Can I

hyperlinks in JEditorPane in a JTable

我们两清 提交于 2019-12-12 09:09:10
问题 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? 回答1:

HTMLEditorKit and Custom tags in the JEditorPane

我们两清 提交于 2019-12-12 02:29:55
问题 I use the instructions to add my own tag http://java-sl.com/custom_tag_html_kit.html class MyParserDelegator extends ParserDelegator { public MyParserDelegator() { try { Field f=javax.swing.text.html.parser.ParserDelegator.class.getDeclaredField("dtd"); f.setAccessible(true); DTD dtd=(DTD)f.get(null); javax.swing.text.html.parser.Element div=dtd.getElement("div"); dtd.defineElement("button", div.getType(), true, true,div.getContent(),null, null,div.getAttributes()); } catch

auto scolling of JEditorPane

笑着哭i 提交于 2019-12-12 01:23:51
问题 I am using a JEditorPane as an editor to write comments in my application. The content type is set "text/plain". When I am writing text in it and the text fills the available space and I go on typing, the text is not moving upward to show the cursor. So I dont know where I am typing and what I am typing since it would be visible. Could you tell me how to always show the caret by moving the above text upwards? Instead, it could be better if I can auto-resize the editor as I am typing. The

jEditorPane handling local images

懵懂的女人 提交于 2019-12-11 22:12:18
问题 I'm working in a wysiwyg editor, with a jEditorPane, right now I'm trying to insert images via a JFileChooser into de editorpane, but it only inserts one image, I don't know how to do it, any ideas? Here's how I'm inserting the image: public void Imagen(){ int im = ImageChooser.showOpenDialog(ImageChooser); if (im == JFileChooser.APPROVE_OPTION){ String Path = String.format("<img src=\"file:\\%s\"alt=\"Image\">", ImageChooser.getSelectedFile().getAbsolutePath()); EditorPane.setText(Path );

Setting the font and style of jeditorpane

陌路散爱 提交于 2019-12-11 19:47:41
问题 I am currently developing an application for this company as my last year of studies project, and in this application there's this function that allows you to print a paper, so i used the jeditorpane obviously, with the Charles Bell HTMLEditorKit for the predefined functions like setting the font and printing, etc... and there's this pre-written text that i have to load from a text file and then the program is supposed to add some text inside the file automatically, and the user also is

How do I style HTML in a JEditorPane?

假如想象 提交于 2019-12-11 19:04:13
问题 I'm completely lost on this. Would I need the CSS that is explicitly referenced in the HTML file? If so, how would I get it, and how would I apply the CSS to the HTML? I read something about JSoup being able to get the CSS. 回答1: See How to add stylesheet for JEditorPane. In general http:// and file:// includes and embedded CSS are no problem. 回答2: Use a style="" attribute in the individual HTML tags 来源: https://stackoverflow.com/questions/14061665/how-do-i-style-html-in-a-jeditorpane

How to setPage() a JEditorPane with a localfile which is outside of the .jar file?

微笑、不失礼 提交于 2019-12-11 18:46:54
问题 My program has the following path in the .jar file src/test/Program.class and my program is as follow... Program.java package test; import java.io.File; import java.io.IOException; import javax.swing.JEditorPane; import javax.swing.JFrame; public class Program { JEditorPane editorPane; public Program() { File file = new File("temp.htm"); try { file.createNewFile(); editorPane = new JEditorPane(); editorPane.setPage(Program.class.getResource("temp.htm")); } catch (IOException e) { e