Set in JEditorPane

hello when iam copying a word for (ex: kiran's) from Microsoft word and pasted it in a html file.
And if i display that file in JEditorPane ,then
it is displaying kiran's as
kiran(and a small square here)s
so the apostraphe is being replaced by a small square.
how can i rectify this problem and the ' is displayed in it.
thankyou.kiran

I had the same problem today. It seems that when I pasted the MS Word document into the HTML file, the apostrophe was translated as a character other that the ASCII apostrophe. They look almost the same but the character code is obviously different. You will have to go through the HTML file and replace the "MS Word" apostrophes with the regular apostrophe. That did the trick for me.

Similar Messages

  • Problem displaying Japanese char set in JEditorPane

    Hi ,
    I am using JEditorPane for displaying html content. If the content is in English
    it is getting displayed properly . In case of Japanese char set like Shift-JIS only square
    boxes is displayed .
    I have tried the following
    1.Installed Japanese font and set regional and language options.
    2.set content type of JEditorPane as text/html and char set=Shift-JIS
    3.Used InputSteamReader for reading html document .While constructing passed char set also.
    4.Used SetText to set html content.
    5.verified font.properties file
    I am Using JDK 1.4.2
    No positive results.
    Kindly help me to resolve this . If it known bug please inform.
    U can connect me at [email protected]
    Thanks in Advance,
    Polu

    Hi,
    Thanks,
    I have tried the approach has mentioned above but still no positive result,
    Pls can u guide me ,so as to what might be the problem,
    Cheers,

  • How to set a jpg image ContentType of JEditorPane

    Hi how can i display an image on a JEditorPane like image.jpg?
    I tried myEditor.setContentType("image/jpeg") but it still displays characters instead of the image.
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    public class Pagina extends JFrame implements Runnable {
         JEditorPane e;
         public Pagina(){
              super("fds");
              e = new JEditorPane();
              e.setEditable(false);
              e.setContentType("image/jpeg");
              Container c = getContentPane();
              c.add(e);
              setSize(400,400);
              setVisible(true);
              Thread t = new Thread(this);
              t.start();
         public void run(){
              while(true){
                   try{
                   e.setPage( "http://10.0.0.5/SnapShot.jpg" );
                   Thread.sleep(1000);
              catch(IOException ioe){}
              catch(InterruptedException ie){}
         public static void main (String [] args) {
              new Pagina();
    }

    In your current app, you are trying to redisplay an image in some infinite loop. This smells bad to me. I am no expert in java graphics, far from it, but if you want to paint a background image within a JEditorPane, since JEditorPane is a component and has to paint itself, you could override its paintComponent method and draw an image inside there using the Graphics object.
    another way is to put the JEditorPane on top of a JPanel that draws your picture. In both instances, I think that you'll need to set the JEditorPane's opaqueness to "false".
    Something like so, perhaps?
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    import javax.swing.BorderFactory;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    class ImageJEditorPane extends JPanel
        private static final String IMAGE_FILE1 = "disc/d1/f/image1.jpg";   
        private static final String IMAGE_URL = "http://10.0.0.5/SnapShot.jpg";
        private BufferedImage myImage = null;
        private JEditorPane editorPane;
        ImageJEditorPane()
            try
                setPreferredSize(new Dimension(800, 650));
                setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
                setLayout(new BorderLayout());
                //myImage = ImageIO.read(new File(IMAGE_FILE1));
                myImage = ImageIO.read(new URL(IMAGE_URL));
                editorPane = new JEditorPane()
                    @Override
                    protected void paintComponent(Graphics g)
                        g.drawImage(myImage, 0, 0, null);
                        super.paintComponent(g);
                editorPane.setPreferredSize(new Dimension(1200, 1000));
                editorPane.setOpaque(false);
                JScrollPane scrollPane = new JScrollPane(editorPane);
                add(scrollPane, BorderLayout.CENTER);
            catch (IOException e)
                e.printStackTrace();
         //or you could do it this way
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            g.drawImage(myImage, 0, 0, null);
        private static void createAndShowGUI()
            JFrame frame = new JFrame("ImageJEditorPane Application");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(new ImageJEditorPane());
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }Edited by: Encephalopathic on Dec 21, 2007 3:09 PM

  • How to know size of HTML page set to Jeditor pane  for printing

    Hi,
    i have to print an HTML doc which may be more no of pages .... ,that is set to jeditorpane and this component will be sent to print method , there i have to decide whether page exists. To do so i have to know how many pages the html doc occupies . how can i know ??
    thanks in advance .......

    Hi,
    i have to print an HTML doc which may be more no of pages .... ,that is set to jeditorpane and this component will be sent to print method , there i have to decide whether page exists. To do so i have to know how many pages the html doc occupies . how can i know ??
    thanks in advance .......

  • Remove Html textarea scrollbar from jeditorpane

    Hi,
    I am using jeditorpane for display a content in my project,
    i am create html code and set to jeditorpane, but in my code i am using textarea for display large text,
    what my problem is in the textarea is not at all wrap and even small text also its show scrollbar,
    i want to remove the scrollbar and wrap properly, can any one give some idea is highly useful to solve my problem.
    my code is
            setContentType("text/html"_);
              HTMLEditorKit kit = new HTMLEditorKit();
              super.setEditorKit(kit);
              StyleSheet styleSheet = kit.getStyleSheet();
              styleSheet.addRule("textarea {style=border:4; overflow:auto; wrap:virtual}");
              styleSheet.addRule("body {color:#000; font-family:times; margin: 1px }");
              StringBuffer sb = new StringBuffer();
            // in this string buffer i am append all the html code
             setText( sb.toString() );Thanks in advance.

    This is the technique I use.
    1. Create 2 identical columns, one with the HTML and one without.
    2. Then conditionally display the columns, one to display in the web page and the other to display in the download. This can easily be done using the request value e.g.
    Condition Type: Request Is NOT Contained within Expression 1
    Expression1: CSV,PDF,RTF,XLS
    I hope that does the trick for you :)
    Simom

  • How to set the physical font in JEditorPane with HTMLEditorKit

    I am now creating a swing application which use JEditorKit to make a HMTL editor by the following code:
    JEditorPane editor = new JEditorPane();
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument doc = new HTMLDocument();
    editor.setEditorKit(kit);
    editor.setDocument(doc);
    editor.setContentType("text/html; charset="+sEncoding);
    editor.getDocument();
    u can see that the encoding of the html file is generated dynamically. At the same time, I also hope that the font is also set dynamically. Moreover, I don't want the font to be installed on each platform, so I am using the following code:
    FileInputStream fis = new FileInputStream("Cyberbit.ttf");
    Font font = Font.createFont(Font.TRUETYPE_FONT, fis);
    Therefore, I can use this font in the Java application. However, how can I make the html file can use this font also? How can I make the HTML file to use this font in the JVM? thx!
    Stephen

    However, how can I make the html file can use this font also? How can I make the HTML file to use this font in the JVM? thx!This is my exact problem!
    Hope you would have got the solution , could you give me some sugesstion..pls?

  • How to set Color of Specific String in JEditorPane?

    I have tried using jp1.setForeground(Color.red) but all the text in JEditorPane are set to red. I want the JEditorPane to display red for all text except a particular string 'xyz'. Can anyone pls help me?
    Thank you.

    Its easier to use a JTextPane. Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html]Using Text Components.
    And here's another thread that will help:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=342068

  • JEditorPane and HTMLEditorKit: can't set alignment after invoking setText

    When i write text into JEditorPane i can change the alignment of this text.
    With getText i get the html-code. After invoking setText() with this html-code the alignment-action does not work.
    Here is some test-code to show this. but the test fails only sometimes.
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.Action;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.text.html.HTMLEditorKit;
    import junit.extensions.jfcunit.JFCTestCase;
    import junit.extensions.jfcunit.JFCTestHelper;
    import junit.extensions.jfcunit.eventdata.KeyEventData;
    import junit.framework.AssertionFailedError;
    public class EditorPaneTest extends JFCTestCase {
      // Private instance variables ( fixtures )
      // ==============================================================================================
      private JFCTestHelper jfcHelper= null;
      private JEditorPane testInstance = null;
      public EditorPaneTest( String testName ) {
        super( testName );
      // Class methods
      // ==================================================================================================================
      public static junit.framework.Test suite() {
        junit.framework.TestSuite suite = new junit.framework.TestSuite( EditorPaneTest.class );
          return new junit.extensions.RepeatedTest( suite , 5 );
      // Instance methods
      // ==================================================================================================================
      // Protected ( setup and teardown test case )
      protected void setUp() throws java.lang.Exception {
        super.setUp();
        junit.extensions.jfcunit.JFCTestHelper.setCurrentTestCase( this );
        jfcHelper = new JFCTestHelper();
      protected void tearDown() throws java.lang.Exception {
        try {
          // Add tearDown code for fixtures here
        } // try
        finally {
          jfcHelper = null;
          junit.extensions.jfcunit.TestHelper.cleanUp( this );
          super.tearDown();
        } // finally
      // Public ( testcases )
      @SuppressWarnings("nls")
      public void testCreation() throws Exception {
        SwingUtilities.invokeAndWait( new Runnable() {
          public void run() {
            testInstance = new JEditorPane();
        assertNotNull( testInstance );
        final JFrame frame = new JFrame( "test" );
        frame.getContentPane().add( testInstance , BorderLayout.CENTER );
        frame.setSize( 800 , 600 );
        frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
        frame.setVisible( true );
        testInstance.setEditorKit( new HTMLEditorKit() );
        Map< String , Action > actionMap = new HashMap< String , Action >();
        Action[] actions = testInstance.getEditorKit().getActions();
        for ( Action a : actions ) {
          actionMap.put( ( String ) a.getValue( Action.NAME ) , a );
        jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_T ) );
        jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_S ) );
        jfcHelper.sendKeyAction( new KeyEventData( this , testInstance , KeyEvent.VK_T ) );
        selectAll();
        Action centerAction = actionMap.get( "center-justify" ); //$NON-NLS-1$
        centerAction.actionPerformed( new ActionEvent( this , ActionEvent.ACTION_PERFORMED , "align" ) );
        final String html = testInstance.getText();
        SwingUtilities.invokeAndWait( new Runnable() {
          public void run() {
            testInstance.setText( html );
        final String htmlAfterInit = testInstance.getText();
        selectAll();
        Action leftAction = actionMap.get( "left-justify" );//$NON-NLS-1$
        leftAction.actionPerformed( new ActionEvent( this , ActionEvent.ACTION_PERFORMED , "align" ) );
        final String htmlAfterAlignLeft = testInstance.getText();
        new alltests.AbstractMockTimeoutVerifier( alltests.AbstractMockTimeoutVerifier.Type.SWING ) {
          public void doVerify() throws AssertionFailedError {
            assertFalse( htmlAfterInit.equals( htmlAfterAlignLeft ) );
            System.out.println(htmlAfterInit); //$NON-NLS-1$ // TODO: Remove
            System.out.println("-------------------------"); //$NON-NLS-1$ // TODO: Remove
            System.out.println(htmlAfterAlignLeft); //$NON-NLS-1$ // TODO: Remove
        }.verify();
      // Private ( helpers )
      private void selectAll() throws AssertionFailedError, InterruptedException{
        SwingUtilities.invokeLater( new Runnable() {
          public void run() {
            testInstance.selectAll(); 
        new alltests.AbstractMockTimeoutVerifier( alltests.AbstractMockTimeoutVerifier.Type.SWING ) {
          public void doVerify() throws AssertionFailedError {
            assertTrue( 0 < testInstance.getSelectedText().length() );
        }.verify();
    }

    I remember having a similiar problem. It was caused by the session not using the properties passed in. I seem to remember I needed to set a system property at startup, but can't remember what it was. JGuru has this to say though:
    Q:
    I'm getting my Session with Session.getDefaultInstance and its not getting changes to the Properties passed in. What's wrong?
    A:
    In getDefaultInstance(Properties props), the Properties are only used in the initial call. Future calls ignore the setting, returning the previously created Session. If you need to change the Properties, like to change SMTP servers, you should use getInstance(Properties props) instead.

  • Suppressing certain HTML tags before setting text to JEditorPane

    Sir,
    I am setting the text(html format) for JEditorPane using the setText(String) method. But I need to suppress all the <IMG> tags that are present in this text before setting it to JEditorPane. Is there any way in which I can write my extended HTMLEditorKit wherein I can check for specific HTML.Tag and prevent it from getting added to the document.
    Can you please help me out with some example.
    Regards,
    Alex

    Instead of trying to extend the HTMLEditorKit, you don't you add a normal method to scan the text for the <IMG> tag and get rid of it yourself before putting it in the JEditorPane using the setText() method. You can try something like this:
    public String removeImgTag(String text) {
       String tmp=text.toLowerCase();
       int i=tmp.indexOf("<img");
       if (i<0) return text;
       int j=tmp.substring(i).indexOf(">");
       return tmp.substring(0,i-1)+tmp.substring(i+j);
    };o)
    V.V.

  • JEditorPane - set http header

    hi
    how to set (or is it even possible) to set http header (in http request) in JEditorPane (to set referrer, user agent, etc.)
    thanks a lot

    Thanks Raja,
    I am not an ITS expert by any means. I need help to work out how use the information in OSS Note 494984 to solve my problem.
    The note seems to be about setting headers on all incoming requests to ITS.
    I need to set the content-type header on an outgoing response generated using a specific (XML) template.
    I did the BC440 course back in 2000 but after 2000 I never did another ITS project, focusing on Java and J2EE instead. So I am not sure how to apply what the OSS Note says. Do I need to assign the content type to a Business HTML parameter in the template? The documentation I have with SAP@Web Studio is not helpful.

  • JEditorPane set color for desired chars

    How can I set color and other parameters for desired chars in JEditorPane or it's better to use some other class.
    Thanks.

    Read this section from the Swing tutorial on "Using Text Components" and then decide which is best for you:
    http://java.sun.com/docs/books/tutorial/uiswing/components/text.html

  • Is there to set one link's color in JEditorPane, when reading HTMl files?

    I jsut want to set ONLY ONE link a certain color. How do I do that?
    Thanks.
    Virum

    If you are just getting the JEditorPane to read in a HTML file then you would have to specify the HTML on the link you want, i.e. set the attributes on the "a" tag or use a style sheet.
    Or course you could dive into the HTMLDocument used by the HTMLEditorKit and set the attributes for the specific "a" tag but then you would have to try and find it in there...good luck!
    Or of course you could modify the HTML file prior to loading it into the editor...

  • How to set Font in JEditorPane

    i have problem set Font in JEditorPane.please help how to set Font in JEditorPane.
    My Code,
    JEditorPane view = new JEditorPane();
    view.setEditable(false);
    view.setContentType("text/html");
    JScrollPane scroll = new JScrollPane(view);
    scroll.setMinimumSize(new java.awt.Dimension(50, 50));
    scroll.setPreferredSize(new java.awt.Dimension(450, 300));
    scroll.setAutoscrolls(true);
    scroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    view.setBorder(null);
    view.setFont(new java.awt.Font("Monospaced", 0, 12));
    view.setDragEnabled(true);
    view.setMargin(new java.awt.Insets(10, 10, 10, 10));
    view.setMinimumSize(new java.awt.Dimension(100, 20));
    view.setPreferredSize(new java.awt.Dimension(450, 300));

    Have a look at SimpleAttributeSet.

  • JEditorPane and HTML Coded Character Set

    Hi.
    How to prevent JEditorPane to convert its content into HTML coded character set (like
    &#1072;&#1073;&#1074;&#1075;&#1076;&#1077;&#1105;&#1078;
    I would like to receive normal unicode string from getText() method.
    Setting content type
    editorPane.setContentType("text/html; charset=ISO-10646");
    has no effect.

    you would have to iterate through the elements of the HTMLDocument in the JEditorPane and look for the HTML tags you are interested in. Once a tag is found its AttributeSet will have the content. I am too lazy to post how it is done again. There are tons of postings in the forum about the topic, so by simply using the search function you should find respective hints.

  • Set default font of JEditorPane ?????

    Hi java gang!
    I am completely lost! I hope that you will be patient with me because I must be doing something very stupid.
    I just want to set the default font of my JEditorPane.
    I tried
    editor.setFont(new Font("SansSerif", Font.PLAIN, 20));
    editor.setText("<html>  <head> </head> " +
                              "<body><font face='sans serif' size='20'> </font></body>");
    UIManager.put("EditorPane.font", new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 24));without success.
    And to not disturb for example Mr. camickr I created a SSCCE ;-)
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EditorTest extends JFrame implements ActionListener {
        JPanel editorPanel;
        public EditorTest() {
            editorPanel = new JPanel();
            this.getContentPane().add(editorPanel, BorderLayout.CENTER);
            JPanel buttonPanel = new JPanel();
            JButton b1 = new JButton("setFont");
            b1.addActionListener(this);
            buttonPanel.add(b1);
            JButton b2 = new JButton("html");
            b2.addActionListener(this);
            buttonPanel.add(b2);
            JButton b3 = new JButton("html2");
            b3.addActionListener(this);
            buttonPanel.add(b3);
            JButton b4 = new JButton("UIManager");
            b4.addActionListener(this);
            buttonPanel.add(b4);
            this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
            this.setPreferredSize(new Dimension(600,400));
            this.pack();
            this.setVisible(true);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public static void main(String[] args) {
            EditorTest test = new EditorTest();
        public void actionPerformed(ActionEvent e) {
            this.editorPanel.removeAll();
            JEditorPane editor = null;
            if (e.getActionCommand().equals("setFont")) {
                editor = createEditorUsingSetFont();
            else if (e.getActionCommand().equals("html")) {
                editor = createEditorUsingHtml();
            else if (e.getActionCommand().equals("html2")) {
                editor = createEditorUsingHtml2();
            else if (e.getActionCommand().equals("UIManager")) {
                editor = createEditorUsingUIManager();
            if (editor != null) {
                this.editorPanel.add(editor);
                this.editorPanel.revalidate();
                this.editorPanel.repaint();
                editor.requestFocus();
                this.printFontAtCaret(editor);
        private JEditorPane createEditorUsingSetFont() {
            JEditorPane editor = new JEditorPane("text/html", "");
            editor.setEditorKit(new HTMLEditorKit());
            editor.setFont(new Font("SansSerif", Font.PLAIN, 20));
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingHtml() {
            JEditorPane editor = new JEditorPane("text/html", "<html>  <head> </head>" +
                    "  <body><font face='sans serif' size='20'> </font></body>");
            editor.setEditorKit(new HTMLEditorKit());
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingHtml2() {
            JEditorPane editor = new JEditorPane("text/html", "");
            editor.setEditorKit(new HTMLEditorKit());
            editor.setText("<html>  <head> </head>  <body>" +
                    "<font face='sans serif' size='20'> </font></body>");
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingUIManager() {
            System.out.println(UIManager.get("EditorPane.font"));
            UIManager.put("EditorPane.font",
                    new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 24));
            System.out.println(UIManager.get("EditorPane.font"));
            JEditorPane editor = new JEditorPane("text/html", "");
            editor.setEditorKit(new HTMLEditorKit());
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private void printFontAtCaret(JEditorPane editor) {
            HTMLDocument doc = (HTMLDocument)editor.getDocument();
            Element element = doc.getCharacterElement(editor.getCaretPosition());
            System.out.println("fontSize " +
                    StyleConstants.getFontSize(element.getAttributes()));
            System.out.println("fontFamily " +
                    StyleConstants.getFontFamily(element.getAttributes()));
    }Please notice that I did non forget to use code format tags! At least one thing I can do right today........
    Annette

    This is really shocking!
    But you may take a look at this:
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class CamicksEditorTest extends JFrame implements ActionListener, CaretListener
        JPanel editorPanel;
        public CamicksEditorTest() {
            editorPanel = new JPanel();
            this.getContentPane().add(editorPanel, BorderLayout.CENTER);
            JPanel buttonPanel = new JPanel();
            JButton b1 = new JButton("setFont");
            b1.addActionListener(this);
            buttonPanel.add(b1);
            JButton b2 = new JButton("html");
            b2.addActionListener(this);
            buttonPanel.add(b2);
            JButton b3 = new JButton("html2");
            b3.addActionListener(this);
            buttonPanel.add(b3);
            JButton b4 = new JButton("UIManager");
            b4.addActionListener(this);
            buttonPanel.add(b4);
            JButton b5 = new JButton("Diagnosis");
            b5.addActionListener(this);
            buttonPanel.add(b5);
            this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    //        this.setPreferredSize(new Dimension(600,400));
    //        this.pack();
              this.setSize(600, 400);
            this.setVisible(true);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public static void main(String[] args) {
            CamicksEditorTest test = new CamicksEditorTest();
        public void actionPerformed(ActionEvent e) {
            this.editorPanel.removeAll();
            JEditorPane editor = null;
            if (e.getActionCommand().equals("setFont")) {
                editor = createEditorUsingSetFont();
            else if (e.getActionCommand().equals("html")) {
                editor = createEditorUsingHtml();
            else if (e.getActionCommand().equals("html2")) {
                editor = createEditorUsingHtml2();
            else if (e.getActionCommand().equals("UIManager")) {
                editor = createEditorUsingUIManager();
            else if (e.getActionCommand().equals("Diagnosis")) {
                editor = new ChickenPox();
                editor.setPreferredSize(new Dimension(500, 300));
            if (editor != null) {
                this.editorPanel.add(editor);
                this.editorPanel.revalidate();
                this.editorPanel.repaint();
                editor.addCaretListener(this);
                editor.requestFocus();
    //            this.printFontAtCaret(editor);
        private JEditorPane createEditorUsingSetFont() {
            JEditorPane editor = new JEditorPane("text/html", "");
    //        editor.setEditorKit(new HTMLEditorKit());
            editor.setFont(new Font("SansSerif", Font.PLAIN, 20));
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingHtml() {
            JEditorPane editor = new JEditorPane("text/html", "<html>  <head> </head>" +
                    "  <body><font face='sans serif' size='20'>HTML1</font></body></html>");
    //        editor.setEditorKit(new HTMLEditorKit());
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingHtml2() {
    //        JEditorPane editor = new JEditorPane("text/html", "");
            JEditorPane editor = new JEditorPane();
              editor.setContentType( "text/html" );
    //        editor.setEditorKit(new HTMLEditorKit());
            editor.setText("<html><head> </head><body>" +
                    "before <font face='sans serif' size='8'>HTML2</font> after</body></html>");
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
        private JEditorPane createEditorUsingUIManager() {
            System.out.println(UIManager.get("EditorPane.font"));
            UIManager.put("EditorPane.font",
                    new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 24));
            System.out.println(UIManager.get("EditorPane.font"));
            JEditorPane editor = new JEditorPane("text/html", "");
    //        editor.setEditorKit(new HTMLEditorKit());
            editor.setPreferredSize(new Dimension(500, 300));
            return editor;
         public void caretUpdate(CaretEvent e)
              JEditorPane editor = (JEditorPane)e.getSource();
            HTMLDocument doc = (HTMLDocument)editor.getDocument();
            Element element = doc.getCharacterElement(editor.getCaretPosition());
            System.out.println("fontSize " +
                    StyleConstants.getFontSize(element.getAttributes()));
            System.out.println("fontFamily " +
                    StyleConstants.getFontFamily(element.getAttributes()));
            class ChickenPox extends JEditorPane {
                public ChickenPox() {
              this.setContentType( "text/html" );
                public void paint(Graphics g) {
                    super.paint(g);
                    Dimension d = this.getSize();
                    Random r = new Random();
                    for (int i=0; i<500; i++) {
                        float f = r.nextFloat();
                        g.setColor(Color.RED);
                        g.fillOval(new Double(r.nextFloat()*d.getWidth()).intValue(),
                                new Double(r.nextFloat()*d.getHeight()).intValue(), 2, 2);
    }So as you can see very easily when you click the Button Diagnosis: My JEditorPanes are just infected with chickenpox (like my kids are.....). So maybe this can explain the strange behavior... And if you run the sample code, just be prepared that your JEditorPanes will be infected, too, in about two weeks.....
    all joking aside: Maybe someone knows what I could do? I will appreciate any answer very much! Thanks a lot!

Maybe you are looking for

  • Converting Unicode to UTF-8 character set through Oracle forms(10g)

    Hi, I am working on oracle forms (10g) where i need to load files containing unicode character set (multilingual characters) to database. but while loading the file , junk characters are getting inserted into the database tables. while reading the fi

  • How we modify print program in script

    hi gurus. how we modify print program in script, please tell elaborately.

  • Get the raw/column number of a left-mouse clicked table cell

    is this possible to get the row/column number of a cell where a mouse is clicked? Accutally, i want to implement a dynamic one column list which the user can "Add" or "Delete" some entries. The "Add" function is all right. The "Delete" function makes

  • Print spool to html

    Hi! Would it be possible to convert print spool to html file in ABAP? Need your help. Thanks, Cherrie

  • Deletion of BP.

    Hi Guys I am trying to delete a BP using BUPA_DEL but its saying that Business Partner still used in Business Transactions. But when i am checking in Activites, all Activities are closed/completed already. Help needed urgently.