Search Results

Search found 29 results on 2 pages for 'jeditorpane'.

Page 1/2 | 1 2  | Next Page >

  • JEditorPane scrolling to the current caret position

    - by Elliott
    I have a JEditorPane which I use to display an HTML document. the document has hyperlinks embedded in it. When a user clicks on a bookmark a position the caret to the associated place in the JeditorPane. The JeditorPane is then suppose to scroll to this position. This works mostly. But, I noticed that if the document has a lot of "break tags" (BR) tags embedded in it, the scrolling does not position the JEditorPane to right place. It's like the tags throw the callebration off. Any suggestions on what to do about this?

    Read the article

  • Java JEditorPane Format

    - by ikurtz
    im trying to implement a Chat feature in my application. i have used 2 JEditorPane. one for holding chat history and the other for sending chat to the previous JEditorPane. the JEditorPane is text/html type. the problem i am having is when i put more than one space between characters it is automatically removed by the parser because it is HTML! how can i make it so, that the spaces are not stripped? example: hello world becomes: hello world. also i am having to parse the html tags so the new messages can be added to the history window. is there a better option than using JEditorPane? if i used JTextPane would it be easier to implement? i would like the chat boxes/panes to be able to handle bold, URL embedding for now. thank you and look forward to your guidance.

    Read the article

  • Java JEditorPane

    - by ikurtz
    ChatGUI im using 2 JEditorPane to transfer text from one to another. once i have transfered the data i do the following: JEditorPane.setText(null); JEditorPane.setCaretPosition(0); but as you can see from the attached image the return action makes the prompt appear a row down. how can i fix this?

    Read the article

  • Move the position in JEditorPane

    - by Joe
    Hi, I've a JEditorPane inside a JDialog. I'm loading a web page when this JDialog is loading. This web page is larger then the JEditorPane size. So I want to display a certain position in the web page by default. For example, I've a 175x200 size jdialog and JEditorPane. I want to display the web page sontent around 150 pixels down. Is there any solutions for this? Or is there any other component which I can used to display web pages and can move to a certain position of the web page at loading time.

    Read the article

  • Even More Steroids for JEditorPane

    - by Geertjan
    Got some help from Ralph today and now the JEditorPane is as I want it, e.g., code folds are now supported once you click in the JEditorPane, though there are still some side effects, since this is not how anyone anticipated NetBeans editor APIs being used. But, so far, the side effects (e.g., now the hyperlinks work, but they open a new JavaScript file when you click on one of them, instead of jumping within the JEditorPane itself) are not so terrible. Error checking is also done now, which wasn't there before, i.e., red underlines and error annotations in the right margin. And maybe it's my imagination, but the editor feels a lot snappier, e.g., in code completion, than before. I've checked in the changes, they're all in this file: http://java.net/projects/nb-api-samples/sources/api-samples/content/versions/7.3/misc/CMSBackOffice2/CMSBackOffice2-editor/src/main/java/com/mycompany/cmsbackoffice2editor/GeneralTab.java

    Read the article

  • Regular Expression, JEditorPane, Self-closing tags

    - by Stephen Swensen
    I'm am using JEditorPane to render basic HTML. But it renders self-closing tags incorrectly, specifically br tags, e.g. <br /> is bad but <br> is good. I would like to use String.replaceAll(regex, "<br>") to fix the HTML, where regex is a regular expression matching any self-closing br tag with case-insensitivity and zero to infinity number of spaces between the "r" and the "/" (e.g., <br/>, <BR/>, <br />, <Br     />, etc.). Thanks to any regular expression experts who can solve this!

    Read the article

  • JEditorPane on Steroids with Nashorn

    - by Geertjan
    Continuing from Embedded Nashorn in JEditorPane, here is the same JEditorPane on steroids with Nashorn, in the context of some kind of CMS backend system: Above, you see heavy reusage of NetBeans IDE editor infrastructure. Parts of it are with thanks to Steven Yi, who has done some great research in this area. Code completion, right-click popup menu, line numbering, editor toolbar, find/replace features, block selection, comment/uncomment features, etc, etc, etc, all the rich editor features from NetBeans IDE are there, within a plain old JEditorPane. And everything is externally extensible, e.g., new actions can be registered by external modules into the right-click popup menu or the editor toolbar or the sidebar, etc. For example, here's code completion (Ctrl-Space): It even has the cool new feature where if you select a closing brace and the opening brace isn't in the visible area, a rectangular popup appears at the top of the editor, to show how the current piece of code begins: The only thing I am missing is code folding! I wish that would work too, still figuring it out. What's also cool is that this is a Maven project. The sources: http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/CMSBackOffice2

    Read the article

  • JEditorPane Code Completion (Part 2)

    - by Geertjan
    Figured it out! No need to create a fake Java file, unlike what I said in part 1, no need to depend on all the Java Editor modules, if you use DialogBinding.bindComponentToDocument, instead of DialogBinding.bindComponentToFile: public final class CountryEditorTopComponent extends TopComponent {     public CountryEditorTopComponent() {         initComponents();         setName(Bundle.CTL_CountryEditorTopComponent());         setToolTipText(Bundle.HINT_CountryEditorTopComponent());         EditorKit kit = CloneableEditorSupport.getEditorKit("text/plain");         jEditorPane1.setEditorKit(kit);         DialogBinding.bindComponentToDocument(jEditorPane1.getDocument(), 0, 0, jEditorPane1);         jEditorPane1.setText("Egypt");     } The above requires a dependency on Editor Library 2, which is where DialogBinding is found. Aside from that, you need all the dependencies required by the Code Completion API, as described in the Code Completion tutorial on the NetBeans Platform Learning Trail. Once you've done that, go to the Project Properties dialog of the application and then in the "ide" cluster, include "Plain Editor" and "Plain Editor Library". I.e., two additional JARs only. These two are needed because you've set the MIME type to "text/plain", which is needed because DialogBinding expects the JEditorPane to have a MIME type. And now everything works. Press Ctrl-Space in your JEditorPane and, because your CompletionProvider is registered in "text/x-dialog-binding" (via the annotation on CompletionProvider), your completion items are displayed. (The only MIME type for binding a document to a component, by default, is "text/x-dialog-binding", which means the next step is for someone to figure out how to support multiple different of such MIME types, since each JEditorPane in your application is likely to require its own specific code completion support.) I think this is a really workable solution for real scenarios where JEditorPanes in NetBeans Platform applications require code completion.

    Read the article

  • Embedded Nashorn in JEditorPane

    - by Geertjan
    Here's a prototype for some kind of backoffice content management system. Several interesting goodies are included, such as an embedded JavaScript editor, as can be seen in the screenshot: Key items of interest in the above are as follows: Embedded JavaScript editor (i.e., the latest and greatest Nashorn technology, look it up, if you're not aware of what that is.) The way that's done is to include the relevant JavaScript modules in your NetBeans Platform application. Make very sure to include "Lexer to NetBeans Bridge", which does a bunch of critical stuff under the hood. The JEditorPane is defined as follows, along the lines that I blogged about recently thanks to Steven Yi: javaScriptPane.setContentType("text/javascript"); EditorKit kit = CloneableEditorSupport.getEditorKit("text/javascript"); javaScriptPane.setEditorKit(kit); javaScriptPane.getDocument().putProperty("mimeType", "text/javascript"); Note that "javaScriptPane" above is simply a JEditorPane. Timon Veenstra's excellent solution for integrating Nodes with MultiViewElements, which is described here by Timon, and nowhere else in the world. The tab you see above is within a pluggable container, so anyone else could create a new module and register their own MultiViewElement such that it will be incorporated into the editor. A small trick to ensure that only one window opens per news item: @NbBundle.Messages("OpenNews=Open") private class OpenNewsAction extends AbstractAction { public OpenNewsAction() { super(Bundle.OpenNews()); } @Override public void actionPerformed(ActionEvent e) { News news = getLookup().lookup(News.class); Mode editorMode = WindowManager.getDefault().findMode("editor"); for (TopComponent tc : WindowManager.getDefault().getOpenedTopComponents(editorMode)) { if (tc.getDisplayName().equals(news.getTitle())) { tc.requestActive(); return; } } TopComponent tc = MultiViews.createMultiView("application/x-newsnode", NewsNode.this); tc.open(); tc.requestActive(); } } The rest of what you see above is all standard NetBeans Platform stuff. The sources of everything you see above is here: http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.3/misc/CMSBackOffice

    Read the article

  • JEditorPane Code Completion

    - by Geertjan
    Code completion in a JEditorPane: Unfortunately, a lot of this solution depends on the Java Editor support in the IDE. Therefore, to use it, in its current state, you'll need lots of Java Editor related JARs even though your own application probably doesn't include a Java Editor. A key thing one needs to do is implement the NetBeans Code Completion API, using the related tutorial in the NetBeans Platform Learning Trail, but register the CompletionProvider as follows: @MimeRegistration(mimeType = "text/x-dialog-binding", service = CompletionProvider.class) Then in the TopComponent, include this code, which will bind all the completion providers in the above location, i.e., text/x-dialog-binding, to the JEditorPane: EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java"); jEditorPane1.setEditorKit(kit); FileObject fob; try {     fob = FileUtil.getConfigRoot().createData("tmp.java");     DataObject dob = DataObject.find(fob);     jEditorPane1.getDocument().putProperty(             Document.StreamDescriptionProperty,             dob);     DialogBinding.bindComponentToFile(fob, 0, 0, jEditorPane1);     jEditorPane1.setText("Egypt"); } catch (IOException ex) {     Exceptions.printStackTrace(ex); } Not a perfect solution, a bit hacky, with a high overheard, but a start nonetheless. Someone should look in the NetBeans sources to see how this actually works and then create a generic solution that is not tied to the Java Editor.

    Read the article

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

    - by Jaguar
    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.printStackTrace(); } } public JEditorPane getEditorPane(){ return editorPane; } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400); frame.setVisible(true); Program p = new Program(); frame.getContentPane().add(p.getEditorPane()); } } The problem is that I have compiled the program in a .jar file. The file.createNewFile(); creates the temp.htm file outside the .jar file So when editorPane.setPage(Program.class.getResource("temp.htm")); is called the file is not found as it searches for file inside the test package. How to setPage() the temp.htm file whiich is outside the .jar file but in the same folder as the .jar file? As the temp.htm is a localfile and I want a relative path instead of an absolute path. Thanks.

    Read the article

  • Can a user-chosen image be inserted directly into a JEditorPane?

    - by JIM
    What I am trying to do is open up a JFilechooser that filters jpeg,gif and png images, then gets the user's selection and inserts it into the JEditorPane. Can this be done? or am i attempting something impossible? Here is a sample of my program.(insert is a JMenuItem and mainText is a JEditorPane) insert.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JFileChooser imageChooser = new JFileChooser(); imageChooser.setFileFilter(new FileNameExtensionFilter("Image Format","jpg","jpeg","gif","png")); int choice = imageChooser.showOpenDialog(mainText); if (choice == JFileChooser.APPROVE_OPTION) { mainText.add(imageChooser.getSelectedFile()); } } }); What i tried to do is use the add method, i know it's wrong but just to give you an idea of what i'm trying to do. Before you complain, i'm sorry about the code formatting, i don't really know all the conventions of what is considered good or bad style. Thank you very much.

    Read the article

  • JEditorPane Code Completion (Part 3)

    - by Geertjan
    The final step is to put an object into the Lookup on key listening in each of the JEditorPanes, e.g., a "City" object for the CityEditorPane and a "Country" object for the CountryEditorPane. Then, within the CompletionProviders, only add items to the CompletionResultSet if the object of interest is in the Lookup. The result is that you can then have different code completions in different JEditorPanes, as shown below: I've also included the Tools | Options | Editor | Code Completion tab, so that the code completion can be customized. The full source code for the example is here: java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/CustomerApp

    Read the article

  • How to use Netbeans platform syntax highlight with JEditorPane?

    - by Volta
    There are many tutorials online giving very complex or non-working examples on this. It seems that people recommend others to use the syntax highlighters offered by netbeans but I am totally puzzled on how to do so! I have checked many many sites on this and the best I can find is : http://www.antonioshome.net/kitchen/netbeans/nbms-standalone.php However I am still not able to use this example (as it is aimed to people who don't want to use the Netbeans platform but just a portion of it) and I am still not sure if I can just use syntax highlighting in a simple plug 'n play way. For example netbeans supports several language highlights by default, can I just use the highlighters in a JEditorPane to parse Ruby/Python/Java for example ? or do I need to write my own parser :-| ? I will really appreciate a small simple example on how to plug syntax highlight in a standalone application using the netbeans platform.

    Read the article

  • Viewing HTML inside Applet without using JEditorPane

    - by Tom
    Hello, I have a small (500kb) swing applet that displays very simple/limited set of small HTML page(s) inside it with JEditorPane, however this does not seem to work 100% fluently, some customers get a blank page displayed without any java exceptions. The page works OK from my machine. I need a more reliable way to show HTML page to all our users. Any ideas if there is a small + free class to use instead of JEditorPane OR is there an easy fix to make it more reliable (non blank) private JEditorPane m_editorPane = new JTextPane(); m_editorPane.setEditable( false); m_editorPane.setBackground(new Color(239 ,255, 215)); m_editorPane.setBounds(30,42,520,478 ); m_editorPane.setDoubleBuffered(true); m_editorPane.setBorder(null); m_editorPane.registerEditorKitForContentType("text/html", "com.xxxxx.SynchronousHTMLEditorKit"); m_editorPane.setPage(ResourceLoader.getURLforDataFile(param.trim()));

    Read the article

  • JScrollPane Scrolls Down with Long Text in JEditorPane

    - by Jim
    Hello, I want to have a JEditorPane inside a JScrollPane. When the user clicks a button, the click listener will create a textEditor, call jscrollpane.setViewPort(textEditor), call textEditor.setText(String) to fill it with editable text, and call jscrollpane.getVerticalScrollBar().setValue(0). In case you're wondering, yes, the setText() must come after the setViewPort() for reasons that aren't on topic. Here is the problem: After the user clicks the button, the JScrollPane's view scrolls all the way to the bottom. I want the scrollbar to be at the top, as per the last line in my click listener. I popped open a debugger, and to my horror, discovered that the jscrollpane's viewport is being forced down to the bottom after the conclusion of the click listener (when pumping filters). It appears that Swing is delaying the population of the editor/jscrollpane until after the conclusion of the clicklistener, but is calling the scrollbar command first. Thus, the undesired behavior. Anyway, I'm wondering if there is a clean solution. It seems that wanting a scrollpane to be scrolled to the top after modification would be a reasonably common requirement, so I'm assuming this is a well-solved problem. Thanks!

    Read the article

  • JEditorPanes, Preferred Size, and printing HTML

    - by Ryan Elkins
    I'm trying to print some HTML directly, without displaying anything to the user. It works currently (somewhat) using a custom JEditorPane that implements Printable. The problem I'm having is that it always wants to use a preferred size of 582px x 560px. If I manually change the size using something like setSize(x,y) it will change the size of the pane, put the content renders at preferred size, not actual size (so it's still 582x560). I can scale it up to fit the page, but it's basically just an enlarged version where the images are all pixelated and the layout is wrong (based on the smaller window size). Inside the print method of my Printable JEditorPane I used this to try and get the size: javax.swing.JWindow wnd = new javax.swing.JWindow(); wnd.setContentPane(this); wnd.setSize(1024,1584); wnd.pack(); Dimension d = wnd.getPreferredSize(); With or without that setSize and/or pack methods on the JWindow the preferred size always comes back as 582x560. I do have control over the html that I'm trying to print but I'd rather not have to rewrite all of that to scale it down so it will print correctly at full size (when scaled up).

    Read the article

  • Setting the a caret in an JEditor Pane causes an exception.

    - by Elliott
    I have a JeditorPane which has some text in HTML format. When I execute the following command int len = editorPane.getText().length(); The value for len is 7473. But then I try to do the following: editorPane.setCaretPosition(4995); And I get the following exception: java.lang.IllegalArgumentException: bad position: 4995 My understanding is that I should only get this exception if the position at which I'm trying to set the caret is less than 0 or greater than the text length. It is neither. How can this be. Thank you, Elliott

    Read the article

  • Problematic tags displaying HTML in Java

    - by Andez
    Hi again, I have the following tag included in my HTML which causes the JEditorPane not to show the HTML output. <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> Not so much a big deal but anyone know why this would happen? Cannot find too much documentation on this - best I came up with was someone having a go a few years ago to see what was supported on retro virus site. At the minute I'm doing a simple find replace on the string which is not good - are there any better ways? I've seen a lot of people saying that RegEx is no good. The code I have used is this._html = this._html.replace( "<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">", ""); Andez

    Read the article

  • Draggable & Resizable Editors

    - by Geertjan
    Thanks to a cool tip from Steven Yi (here in the comments to a blog entry), I was able to make a totally pointless but fun set of draggable and resizable editors: What you see above are two JEditorPanes within JPanels. The JPanels are within ComponentWidgets provided by the NetBeans Visual Library, which is also where the special border comes from. The ComponentWidgets are within a Visual Library Scene, which is within a JScrollPane in a TopComponent. Each editor has this, which means the NetBeans Java Editor is bound to the JEditorPane: jEditorPane1.setContentType("text/x-java"); EditorKit kit = CloneableEditorSupport.getEditorKit("text/x-java"); jEditorPane1.setEditorKit(kit); jEditorPane1.getDocument().putProperty("mimeType", "text/x-java"); A similar thing is done in the other JEditorPane, i.e., it is bound to the XML Editor. While the XML Editor also has code completion, in addition to syntax coloring, as can be seen above, this is not the case for the JEditorPane bound to the Java Editor, since the JEditorPane doesn't have a Java classpath, which is needed for Java code completion to work.

    Read the article

  • JPanel: both implementing my own paintComponent() and rendering children doesn't work

    - by Paul Marshall
    I'm extending a JPanel to display a game board, and adding a JEditorPane at the bottom to hold some status text. Unfortunately, the game board renders just fine, but the JEditorPane is just a blank gray area until I highlight the text in it, when it will render whatever text is highlighted (but not the rest). If I'm understanding Swing right, it should work, because super.paintComponent(g) should render the other children (i.e., the JEditorPane). Tell me, o great stackoverflow, what bonehead mistake am I making? public GameMap extends JPanel { public GameMap() { JEditorPane statusLines = new JEditorPane("text/plain","Stuff"); this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS)); this.add(new Box.Filler(/*enough room to draw my game board*/)); this.add(statusLines); } public void paintComponent(Graphics g){ super.paintComponent(g); for ( all rows ){ for (all columns){ //paint one tile } } } }

    Read the article

  • Rendering HTML in Java

    - by ferronrsmith
    I am trying to create a help panel for an application I am working on. The help file as already been created using html technology and I would like it to be rendered in a pane and shown. All the code I have seen shows how to render a site e.g. "http://google.com". I want to render a file from my pc e.g. "file://c:\tutorial.html" This is the code i have, but it doesn't seem to be working. import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import java.awt.Color; import java.awt.Container; import java.io.IOException; import static java.lang.System.err; import static java.lang.System.out; final class TestHTMLRendering { // ------------------------------ CONSTANTS ------------------------------ /** * height of frame in pixels */ private static final int height = 1000; /** * width of frame in pixels */ private static final int width = 1000; private static final String RELEASE_DATE = "2007-10-04"; /** * title for frame */ private static final String TITLE_STRING = "HTML Rendering"; /** * URL of page we want to display */ private static final String URL = "file://C:\\print.html"; /** * program version */ private static final String VERSION_STRING = "1.0"; // --------------------------- main() method --------------------------- /** * Debugging harness for a JFrame * * @param args command line arguments are ignored. */ @SuppressWarnings( { "UnusedParameters" } ) public static void main( String args[] ) { // Invoke the run method on the Swing event dispatch thread // Sun now recommends you call ALL your GUI methods on the Swing // event thread, even the initial setup. // Could also use invokeAndWait and catch exceptions SwingUtilities.invokeLater( new Runnable() { /** * } fire up a JFrame on the Swing thread */ public void run() { out.println( "Starting" ); final JFrame jframe = new JFrame( TITLE_STRING + " " + VERSION_STRING ); Container contentPane = jframe.getContentPane(); jframe.setSize( width, height ); contentPane.setBackground( Color.YELLOW ); contentPane.setForeground( Color.BLUE ); jframe.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); try { out.println( "acquiring URL" ); JEditorPane jep = new JEditorPane( URL ); out.println( "URL acquired" ); JScrollPane jsp = new JScrollPane( jep, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); contentPane.add( jsp ); } catch ( IOException e ) { err.println( "can't find URL" ); contentPane.add( new JLabel( "can't find URL" ) ); } jframe.validate(); jframe.setVisible( true ); // Shows page, with HTML comments erroneously displayed. // The links are not clickable. } } ); }// end main }// end TestHTMLRendering

    Read the article

  • Asciidoctor / NetBeans

    - by Geertjan
    With Jason Lee's NetBake plugin (https://bitbucket.org/jdlee/netbake), when you've installed JRuby and then the Asciidoctor gem, you're good to go to use Asciidoctor with NetBeans IDE. New Asciidoc files can be created, which have a Source view... ...and a Visual view. The current content of the text editor is parsed by the Asciidoctor gem and the resulting HTML is displayed in a JEditorPane: Awestruct support is also part of the NetBake plugin, with a new project type and other related features. An Options window is included for configuring the plugin: I've been in touch with Jason and we're discussing separating the Asciidoctor parts from the Awestruct parts and then putting them seperately as plugins on the NetBeans Plugin Portal.

    Read the article

1 2  | Next Page >