jtextpane

How to highlight keywords in java while opening a file and while the user is typing

妖精的绣舞 提交于 2019-12-01 14:30:19
So I am trying to highlight the keywords in java,which I have stored in a text file, as the user opens a .java file or writes to .java file. I think I know how to tell if the file is of the right type. However, I do not know how to change the color of certain keywords. If anyone could help out that would be great because right now it's pretty confusing. I was wondering if I could use my replace function somehow. I have tried to go about trying to do this with the few methods I have, yet it's still not clear. I have taken out he majority of the methods and listeners, just know they are there

How to prevent JScrollPane arrow key handling from moving caret when Scroll Pane wraps Text Pane

核能气质少年 提交于 2019-12-01 14:12:13
I have the following requirements: I need a scrollable JTextPane. The user may type into this text pane, or text may be inserted into it that is not typed by the user. Think something like an IM window. Although the window must be scrollable to allow the user to review text previously typed, the caret should never move from its position at the end of the text. Any text entered by the user will always appear at the end. In JTextPane, when the user scrolls with the scroll bar, the caret does not move. The viewport is adjusted. However, when the user presses the up and down arrow keys, the

JTextPane - Bullet with HTMLEditorKit list not rendering correctly unless I do setText(getText()) and repaint

烂漫一生 提交于 2019-12-01 14:06:23
I have: JTextPane jtextPane = new JTextPane(); jtextPane.setEditorKit(new HTMLEditorKit()); ... Then later I try to add an unordered list button to the toolbar such that the action is: Action insertBulletAction = HTMLEditorKit.InsertHTMLTextAction ("Bullets", "<ul><li> </li></ul>", HTML.Tag.P, HTML.Tag.UL); JButton insertBulletJButton = new JButton(insertBulletAction); And this does include the proper code if I take a dump of the html that's generated. However it will be rendered really badly, as in not even close to reasonable as illustrated below: However if I do: jtextPane.setText(jtextPane

JTextPane - Bullet with HTMLEditorKit list not rendering correctly unless I do setText(getText()) and repaint

怎甘沉沦 提交于 2019-12-01 13:21:27
问题 I have: JTextPane jtextPane = new JTextPane(); jtextPane.setEditorKit(new HTMLEditorKit()); ... Then later I try to add an unordered list button to the toolbar such that the action is: Action insertBulletAction = HTMLEditorKit.InsertHTMLTextAction ("Bullets", "<ul><li> </li></ul>", HTML.Tag.P, HTML.Tag.UL); JButton insertBulletJButton = new JButton(insertBulletAction); And this does include the proper code if I take a dump of the html that's generated. However it will be rendered really badly

How to highlight keywords in java while opening a file and while the user is typing

混江龙づ霸主 提交于 2019-12-01 12:49:55
问题 So I am trying to highlight the keywords in java,which I have stored in a text file, as the user opens a .java file or writes to .java file. I think I know how to tell if the file is of the right type. However, I do not know how to change the color of certain keywords. If anyone could help out that would be great because right now it's pretty confusing. I was wondering if I could use my replace function somehow. I have tried to go about trying to do this with the few methods I have, yet it's

highlighting the word in java

两盒软妹~` 提交于 2019-12-01 11:59:31
I am triying to highlight a word, but only .length()-2 at 1st time,delay and then last 2 words.The first words are highlighted but it is not highlighting the last two words after delay.please help. here is the code: import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JTextPane; import javax.swing.SwingUtilities; import

Getting style from any offset in JTextPane

心已入冬 提交于 2019-12-01 11:13:43
Is there a way to get Style , a style name or just even compare whether Style at a certain position of JTextPane with the style I gave the text when inserting? Because for my purpose I created custom JTextPane , StyledDocument and DocumentFilter . So I could choose Style to be used for say regular letters and another Style for numbers. I have also toggle button which while toggled sets DocumentFilter to format numbers differently and while not toggled numbers format regularly so at the end you can't distinguish which numbers have been affected just according to JTextPane's getText() method.

Getting style from any offset in JTextPane

南楼画角 提交于 2019-12-01 08:15:03
问题 Is there a way to get Style , a style name or just even compare whether Style at a certain position of JTextPane with the style I gave the text when inserting? Because for my purpose I created custom JTextPane , StyledDocument and DocumentFilter . So I could choose Style to be used for say regular letters and another Style for numbers. I have also toggle button which while toggled sets DocumentFilter to format numbers differently and while not toggled numbers format regularly so at the end

Swing JDialog/JTextPane and HTML links

我的未来我决定 提交于 2019-12-01 07:24:35
问题 I am using an html page inside a swing JTextPane in a JDialog. In the html I have a <a href="mailto:email@adress.com">John</a> When I view the web page via an explorer when the mouse goes to the link I can see the mailto . When I press the link I get the error "no default mail client installed", but I guess this is due to in my PC I have not configured Outlook or some other program. When I open the JDialog from my Swing application, I see John highlighted as a link, but when I press the link

How do I allow a user to change his font in a JTextPane using a JComboBox?

こ雲淡風輕ζ 提交于 2019-12-01 07:21:45
问题 I'm finding the amount of helpful documentation/tutorials on the internet are lacking when it comes to the topic of JTextPanes. I'm trying to do a simple text processor, and I want it to be able to select a font family from a JComboBox that populates itself based on the fonts a user has installed on their system. However, no matter what I try with experimenting, I can't figure out how to make it work. What I have is a toolbar class that is built off of a JTextPane. Currently, it has a bunch