My question in JEditorPane

hi everyone , i have one question about JEditorPanel ,wheen have a html page in it , there are are some css in it;
when my html page dispaly in JEditorPane i find it is different when see in firefox explorer, the css is not work well,
what can i do Hthe jeditorPane is not supported for css????
thks,
Edited by: elementkaka on Aug 6, 2009 4:18 AM

Yup. JEditorPane has only rudimentary support for HTML.
what can i doNever used it myself, but you could take a look at the [_jdic browser component_|https://jdic.dev.java.net/documentation/Specification.html].
db

Similar Messages

  • A shared Text editor - question about JEditorPane

    Hi there,
    I'm trying to make a shared Text Editor. So far I have the ability to pass messages across from one client to another. I have all the GUI elements in the "main" Class, and the Connection elements in separate Classes; in particular the receivedPacket method which listens for specific packets. Now I'm able to print in my Terminal window the received packets (via a simple System.out.println call). Is it possible to grab the packet information from the "main" Class and then append that information to the JEditorPane (which has been constructed in the main Class)? Or would it be better to create the JEditorPane in the Class with the receivedPacket and then add the information straight away to the editor window?
    Thanks
    :)

    Thanks for the guidance, I think you're right. Nice to hear you've done something similar.
    What I have up and running is:
    1) GUI elements created in the main class (Class Exchange)
    2) A Connection class that handles the connection to the server and adds packet listeners to the incoming packets (Class Connection)
    3) A class that filters and stores the packets (Class Comms)
    Now I'm using a protocol called Jabber (instant messaging protocol) so I'm using the JabberBeans library for all Jabber stuff (i.e. Connection and packet listeners etc..). Now the receivedPackets method within the Comms Class then extracts the <body> of what I want to another method within the Comms Class which then returns that String value. This works as it prints to the Terminal window when run and packets are received.
    What I'm having difficulty in understanding (although I think its straightforward) is why I can't take that returned value and have it update in my JEditorPane window (which is in the main Class (Exchange)), it doesnt like it for some reason and complains about something from the JabberBeans library.
    I'm unsure about how to update the JEditorPane; would it be to write a method in the main class that calls in the returned <body> String value (which is what I thought would be right)? Or is there something else I've missed. In the JabberBeans API the returned value is of type String, I'm guessing that maybe I need to move that into a StringBuffer for the sake of the JEditorPane.. Or is that just guessing?
    Thanks for the help, hope you get a moment..
    AB
    :)

  • Quick Question : RE: JEditorPane

    Hi,
    I have developed a GUI that contains a JEditorPane. When I mouse over some of the Links in the appearing web page the cursor changes and the link works, however some of the links do NOT change the cursor and they are not acessible.
    Why is this and what can I do to fix it??
    Thanks in advance.
    L.

    They are different. They are not straight forward links. They are like mouse over buttons down the side of the page.
    Here is my HyperlinkListener
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    htmlPane.addHyperlinkListener(new HyperlinkListener(){
    // Hyperlink Listener
    public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    htmlPane = (JEditorPane) e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
    HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
    HTMLDocument doc = (HTMLDocument)htmlPane.getDocument();
    doc.processHTMLFrameHyperlinkEvent(evt);
    startLoading();
    } else {
    try {
    htmlPane.setPage(e.getURL());
    urlField.setText(e.getURL().toExternalForm());
    startLoading();
    } catch (Throwable t) {
    t.printStackTrace();
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    What can I add into this to include such elements in a HTML page?

  • Question about JEditorPane

    I've loaded a HTML in e JEditorPane. What I want is to get html's tag <TITLE>.
    I've tried whith
    HTMLDocument htmlDoc = (HTMLDocument)jep.getDocument();
    //where jep is JEditorPane
    Element root = htmlDoc.getDefaultRootElement(); // Extract root element
    System.out.println("Root element: " + root.getName());
    int childCount = root.getElementCount();
    System.out.println("Children:\n");
    for (int i = 0; i < childCount; ++i){
    System.out.println(i + 1 + " - \"" + root.getElement(i).getName() + '\"');
    with this fragment I can't see de <TITLE>, what I'm doing bad?
    thanks in advance

    try this;
    HTMLDocument htmlDoc = (HTMLDocument)jep.getDocument();
    Element root = htmlDoc.getDefaultRootElement(); // Extract root element
    debug(root);
    private void debug(Element root){
    System.out.println("Root element: " + root.getName());
    int childCount = root.getElementCount();
    System.out.println("Children:\n");
    Element elem;
    for (int i = 0; i < childCount; ++i){
    elem = root.getElement(i);
    System.out.println(i + 1 + " - \"" + elem.getName() + '\"');
    if(elem.getElementCount() > 0)
    debug(elem);

  • Question on JEditorPane

    Hi All,
    I have a created a small html page which basically have some details of name of the tool etc..and at last i am provided a marquee tag in this way
    <FONT SIZE="7" FACE="courier" COLOR="#009ACD"><MARQUEE WIDTH=100% BEHAVIOR=ALTERNATE  BGColor=WHITE>THANK YOU..!!!!</MARQUEE></FONT>   After this i am linking this htmp page with my JEditorPane but in the EditorPane window i dont see "thank you" moving,whereas same is seen when i directly run the .html file.
    Any idea why this behaviour is seen??
    Thanks in advance.
    regards,
    Viswanadh

    http://java-sl.com/marquee.html
    you can extend HTMLEditorKit and add the feature. See simple example above.
    Regards,
    Stas

  • How Jaws works?

    Does anybody know how Jaws works?
    What component will be read by Jaws when it's container becomes active windows?
    For example: JDialog
    Environment: Jaws 7.1, windows xp, jdk1.5 , JAB2.0.1
    1. If dialog just contains a JLabel, nothing will be read.
    2. If u use setFocusable(true) to JLabel, Jaws will read dialog title and two times the content of JLabel.
    3. If dialog contains a JTextField, Jaws will read dialog title and two or three times the contents of JTextField.
    Here the code you can try
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class DialogTest {
         protected JFrame frame = null;
         private static int choice = 1;
         public DialogTest(){
              frame = new JFrame("Just a frame");
              frame.setSize(500, 400);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel = new JPanel();
              JButton button1 = new JButton(new MyAction("open dialog"));
              panel.add(button1);
              button1.addKeyListener(new KeyAdapter(){
                   public void keyTyped(KeyEvent e) {                    
                        if(KeyEvent.VK_ENTER == e.getKeyChar()){
                             onOpen();
              frame.getContentPane().add(panel);
              frame.setVisible(true);          
         private void onOpen(){
              JDialog dialog = new JDialog(frame,"Jaws Test Dialog");
              JPanel jp = new JPanel();
              JLabel jl = new JLabel("Will be read by Jaws label");
              JTextField jtf = new javax.swing.JTextField("Will be read by Jaws text field");
              switch(choice){
              case 1:
                   jp.add(jl);
                   break;
              case 2:
                   jp.add(jl);
                   System.out.println(jl.isFocusable());
                   jl.setFocusable(true);
                   break;
              case 3:
                   jtf.setEditable(false);
                   jtf.setBackground(jp.getBackground());
                   jtf.setBorder(javax.swing.BorderFactory.createEmptyBorder());
                   jp.add(jtf);
                   break;
              default :
                   jp.add(jl);
              dialog.getContentPane().add(new JPanel().add(jp));
              dialog.setSize(300, 250);
              dialog.setVisible(true);
         public static void main(String[] args){
              choice = 1;//CHANGE THIS TO TEST DIFFERENT CASE 1 2 3
              new DialogTest();
         class MyAction extends AbstractAction{
              public MyAction(String name){
                   super(name);
              public void actionPerformed(ActionEvent e) {
                   onOpen();
    }Please give your point of view to help me, I am totally confused by this.

    Sorry for resurrecting this 4 year old thread, but I recently encountered the same problem and found a solution.
    You need to
    1. modify the accessible tree to skip the JScrollPane and JViewPort
    2. avoid sending accessible property-changed events from the JEditorPane
    Full details including an example here: [Stack Overflow|http://stackoverflow.com/questions/6684389/jeditorpane-jscrollpane-and-accessibility/6693843#6693843].
    If anyone has any insights into why this works, I would very much appreciate hearing it.
    Best regards,
    Rasmus Faber.

  • JEditorPane question

    Hello Gurus,
    Can some one help me with this.
    I read a page using URL
    after all the stuff I get the page( which is an HTML text) and display it in JEditorPane,it shows the html part ok but it just prints out the javascript on the page as text and it does not do anything when I click on a link on this page,I am new to this swing stuff,so please bare with me if my questions do not reflect me as an intellectual :-)

    JEditorPane and HTMLDocument don't have code built in for parsing and formatting javascript. If you're going to try to correct this, take a look at the HTMLDocument.HTMLParser class

  • HTML in JEditorPane question

    Hello
    I am having trouble with displaying HTML with image maps in JEditorPane component. I am trying to load a simple html file as follows:
    <html>
    <IMG SRC="monk.gif" HEIGHT="255" WIDTH="262" ISMAP USEMAP="#mapareas">
    <map NAME="mapareas">
    <area SHAPE=CIRCLE COORDS="107,158 132,162" HREF="basic.htm" ALT="Basic Page">
    <area SHAPE=default HREF="index.html">
    </MAP>
    </html>
    There is no problem with displaying the image. It's rendered fine without any problem. But, When I click on the circle area, I can't seem to get the URL corresponding to the map area. I tried the HyperlinkEvent::getDescription() and HyperlinkEvent::getURL() methods and both of them return the reference to the map as opposed to the reference specified for the specific map area ( in my case, "sample.map" instead of "basic.htm" ).
    Can someone tell me if HTML with image maps is supported in EditorPane? if so, how do I get the reference to the map area clicked?
    thanks in adv
    Venkat Kota

    JTextComponent.viewToModel
    then get the element at that location, either the character or
    paragraph element, then get its StyleContext.NameAttribute value, which is a HTML.Tag.
    That was a fun walk round the API, to find out more, I recomend reading through JTextComponent, and its Model/View Split section.
    The the Element and View interfaces.

  • JEditorPane HTML Question

    Hi,
    I have a JEditorPane that I am using to display various HTML pages that I programatically generate. When the user selects a menu item, the HTML page changes. I change the HTML page by calling the JEditorPane.setText() method. All that works fine, but I am running into some funny behavior. When I show a new HTML page, the JEditorPane seems to jump the scrollbar so that you are looking at the very bottom of the html page. I tried to call scrollRectToVisible() just after setText(), but that doesn't seem to do anything. Does anyone know how I can make the JEditorPane scroll to the top of the page when I change the text? Thanks a lot. Any help is appreciated.
    --Reg                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hey bbritta,
    Thanks, that did it. I guess it helps to read the docs more!!

  • JEditorPane and JTextarea question

    I have loaded a HTML file into JEditorPane.
    When I click on a hyperlink in the HTML page, that particular
    link should be invoked in the browser(new window). But, if I click
    on the hyperlink it opens the page into the JEditorPane itself.
    I tried using the hyperlink html anchor tag which includes this attribute:
    target="_blank". It should launch in its own window.But, it
    does not work. How do I make it work? Please help

    I think when the target attribute in the hyperlink is set as target = "_blank" in the html document , then the contents has to be displayed in a new window.
    this html document is displayed in the JEditorPane. The html document has the links set as
    This text is a link to a google page
    The google page is displayed in the JEditorPane itself and not in a new browser window.

  • JEditorPane Question Re setContentType

    I want to place some HTML into a JEditorPane and display it as HTML. Then, I have a button that toggles the display to display the HTML markup itself by setting the content type to "plain/text". What is the correct way to accomplish this and cause the UI to visually update? I've tried every combo of repaint, updateComponentUITree, invalidate, validate, etc.
    Second part: I have a JEditorPane displaying the HTML produced by a transformation of XML. I have a button to allow them to toggle the transformed view to the raw XML view. Obviously, it's not the same String, so I'm calling setContentType, followed by setText, but the UI does not update. What is the correct way to do this?
    Thanks

    OK, so I seem to have solved my problem. Here is what my code ended up looking like. The preview StringBuffer contains either XML or the XML transformed into HTML. The corresponding String previewOutputMethod contains either "text/plain" or "text/html", respectively.
                        EditorKit kit = previewEditorPane.getEditorKitForContentType(previewOutputMethod);
                        this.previewEditorPane.setEditorKit(kit);                                                
                        this.previewEditorPane.setText(preview.toString());
                        this.previewEditorPane.setCaretPosition(0);I suspected that it was some sort of problem with the editor kit being reset when I called setText. So, I assume that by calling getEditorKitForContent(String type) I'll be getting the same instance that was registered for the component for that mimetype rather than creating new EditorKit instances willy nilly. I'll check that out later.

  • JEditorPane Question -- Help

    Dear All,
    I have found that i use the method JEditorPane.setPage(URL) to display the HTML successfully, however, if I use the setText(HTMLSource) which will display a plain white page with no content, the HTML Source is just the same as the page content of the first method used.
    I have checked that the document get from JEditorPane is nothing. Can anyone tell me why? How can I display the content successfully with setText() method? (Because i have changed the text embedded in the HTML Source, not invlove HTML Tag)
    Please help!
    Thanks alot
    KI

    Debugging tip. Whenever you have a problem create a simple program to test the feature you are having a problem with. That way you can post code so people don't have to guess what you have done.
    I have included such a sample program that works. Note that the code is very generic, only 3 lines of code deal directly with the editor pane. This way you can reuse the code for other problems.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class TestEditorPane extends JFrame
    public TestEditorPane()
         JPanel panel = new JPanel();
              panel.setPreferredSize( new Dimension(200, 200) );
         setContentPane( panel );
              JEditorPane ep = new JEditorPane();
              ep.setContentType( "text/html" ); // you are probably missing this
              ep.setText( "<html><body>This is a <b>test</b><body></html>" );
              panel.add( ep );
    public static void main(String[] args)
    TestEditorPane frame = new TestEditorPane();
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.pack();
    frame.setVisible(true);

  • JEditorPane questions...

    Hi
    Some of these topics have been raised hundreds of times before, but i have never seen a reply i could use.. so here goes again:
    I have made a small program - java search tool, used to search the java forum, api ect. and displaying the result in a JEditorPane.
    The trouble is that JEditorPane dont present the HTML very good.
    You can take a look at the program , to see what i mean - the default page is http://java.sun.com - and that ain't looking good either..
    you can find the program here...
    http://www.kobberup.dk/java_search/download/java_search.jar
    The second issue i have whit JEditorPane is, that when i use setURL the focus on the page currently viewed is shifted to the top of the page, for instance, you have scrolled down on a page, and then clicks on a hyperlink. Then the focus shifts to the top of the page, before the new page is loaded - it only lasts for a second, but it can confuse users of the program...
    If you have some comments on the program, or to the problems raised in this post, please reply :)
    -regards
    Anders Kobberup

    Really - no one has any suggestions ??

  • Question about JTextPane, JEditorPane in JApplet?

    Hello,
    I was hoping to display the results of a small piece of html code in a JApplet, I know in the jdk we can use a JTextPane or JEditorPane to display the results of html. But can we use the JTextPane or JEditorPane in a JApplet.
    Thanks

    That really depends on:
    1) whether the HTML is well formed. JEditorPane has problems with any html that is not well formed. For example, <b><p>test</b></p> is not well formed.
    2) whether you want to write your own html viewer
    3) whether you can ensure that users will have a JVM version recent enough to use the JEditorPane - 1.3 is probably the first version it was introduced.

  • JEditorPane Question: Enlarging

    Hi!
    I'm trying to overally enlarge the contents of a JEditorpane, by some x factor. This enlargement includes fonts(of different types), images, headers, etc..
    I've tried some avenues, but to know avail, if anyone could point me in a good direction that would be most appreciated
    Thanks!

    OK, so I seem to have solved my problem. Here is what my code ended up looking like. The preview StringBuffer contains either XML or the XML transformed into HTML. The corresponding String previewOutputMethod contains either "text/plain" or "text/html", respectively.
                        EditorKit kit = previewEditorPane.getEditorKitForContentType(previewOutputMethod);
                        this.previewEditorPane.setEditorKit(kit);                                                
                        this.previewEditorPane.setText(preview.toString());
                        this.previewEditorPane.setCaretPosition(0);I suspected that it was some sort of problem with the editor kit being reset when I called setText. So, I assume that by calling getEditorKitForContent(String type) I'll be getting the same instance that was registered for the component for that mimetype rather than creating new EditorKit instances willy nilly. I'll check that out later.

Maybe you are looking for