JEditorPane and OutOfMemoryError

Hello,
I'm using a JEditorPane to display a set of html pages. I have two main problems, which a general search tells me is quite common. First of all the CSS isn't recognised, so highlighted text is displayed as plain text. But more importantly, I Get OutOfMemoryErrors for loading relatively small pages - if the file contains only text there is no problem loading it, however if one or more images are embedded in the html more often than not an OutOfMemoryError occurs. The files are each less than 100KBs, but there could be anything form 1 to more than 10 in a single file.
Has anyone found a way to resolve especially the second problem?
Aba-Sah
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
     at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
     at java.awt.image.Raster.createPackedRaster(Raster.java:458)
     at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
     at sun.awt.image.ImageRepresentation.createBufferedImage(ImageRepresentation.java:223)
     at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:475)
     at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:120)
     at sun.awt.image.JPEGImageDecoder.sendPixels(JPEGImageDecoder.java:97)
     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:119)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
     at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
     at java.awt.image.Raster.createPackedRaster(Raster.java:458)
     at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
     at sun.awt.image.ImageRepresentation.createBufferedImage(ImageRepresentation.java:223)
     at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:475)
     at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:120)
     at sun.awt.image.JPEGImageDecoder.sendPixels(JPEGImageDecoder.java:97)
     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:119)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
     at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
     at java.awt.image.Raster.createPackedRaster(Raster.java:458)
     at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
     at sun.awt.image.ImageRepresentation.createBufferedImage(ImageRepresentation.java:223)
     at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:475)
     at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:120)
     at sun.awt.image.JPEGImageDecoder.sendPixels(JPEGImageDecoder.java:97)
     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:119)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
     at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
     at java.awt.image.Raster.createPackedRaster(Raster.java:458)
     at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
     at sun.awt.image.ImageRepresentation.createBufferedImage(ImageRepresentation.java:223)
     at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:475)
     at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:120)
     at sun.awt.image.JPEGImageDecoder.sendPixels(JPEGImageDecoder.java:97)
     at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
     at sun.awt.image.JPEGImageDecoder.produceImage(JPEGImageDecoder.java:119)
     at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
     at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
     at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)

thanks, it seems fine with 512M, all the images are able to load without it breaking.

Similar Messages

  • How to load a text file int JEditorPane and highlight some words (Urgent !)

    I want to load a text file into a JEditorPane and then highlights some keywords such as while,if and else.I am using an EditorKit in order to style the JEditorPane. I have no difficulty while giving the input through the keyboard but lots of exceptions are thrown if i try to load the string from a file.

    Hi,
    I think the setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace) will solve the problem.
    You can create your own Styled Document and set it to the Editor Pane.

  • Apply formatting in a JEditorPane and export the content in HTML.

    Hi,
    I'm writing, a program to allow the user to enter a formated text and even add images in a JEditorPane.
    Here is a simple sample of the code:
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;              //for layout managers and more
    import java.awt.event.*;        //for action events
    import java.net.URL;
    import java.io.IOException;
    public class EditorPane extends JPanel{
        private String newline = "\n";
        private JPanel buttonPanel;
        private JPanel textPanePanel;
        private JEditorPane myEditorPane;
        private JButton boldButton;
        private JButton colorButton;
        private JButton imgButton;
        private JButton saveButton;
         public EditorPane() {
            createGUI();
        private void createGUI() {
            buttonPanel = new JPanel();
            boldButton = new JButton("Bold");
            boldButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    boldButtonActionPerformed(evt);
            colorButton = new JButton("Color");
            colorButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    colorButtonActionPerformed(evt);
            imgButton = new JButton("Image");
            imgButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    imgButtonActionPerformed(evt);
            saveButton = new JButton("Save");
            saveButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    saveButtonActionPerformed(evt);
            buttonPanel.setLayout(new GridLayout(1, 4));
            buttonPanel.add(boldButton);
            buttonPanel.add(colorButton);
            buttonPanel.add(imgButton);
            buttonPanel.add(saveButton);
            textPanePanel = new JPanel();
            textPanePanel.setLayout(new BorderLayout());       
            myEditorPane = this.createEditorPane();
            JScrollPane paneScrollPane = new JScrollPane(myEditorPane);
            textPanePanel.add(paneScrollPane, BorderLayout.CENTER);
            this.setLayout(new BorderLayout());
            this.add(buttonPanel, BorderLayout.NORTH);
            this.add(textPanePanel, BorderLayout.CENTER);
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                     JFrame frame = new JFrame("TextSamplerDemo");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   EditorPane newContentPane = new EditorPane();
                    //newContentPane.setOpaque(true); //content panes must be opaque
                    frame.setContentPane(newContentPane);
                    frame.pack();
                    frame.setSize(300,300);
                    frame.setVisible(true);
    private JEditorPane createEditorPane() {
            JEditorPane editorPane = new JEditorPane();
            editorPane.setEditable(true);
            java.net.URL helpURL = TextSamplerDemo.class.getResource(
                                            "simpleHTMLPage.html");
            if (helpURL != null) {
                try {
                    editorPane.setPage(helpURL);
                } catch (IOException e) {
                    System.err.println("Attempted to read a bad URL: " + helpURL);
            } else {
                System.err.println("Couldn't find file: simpleHTMLPage.html");
            return editorPane;
        private void boldButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("boldButtonNextActionPerformed");
        //myEditorPane
            // TODO add your handling code here:
        private void colorButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("colorButtonActionPerformed");
            // TODO add your handling code here:
        private void imgButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("imgButtonActionPerformed");
            // TODO add your handling code here:
        private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("saveButtonActionPerformed");
        String newStr = new String("this is the new String");
        //newStr.setFont(new java.awt.Font("Tahoma", 0, 14));
        this.myEditorPane.replaceSelection("sdfsdfsd");
            // TODO add your handling code here:
    }and the HTML Code of simpleHTMLPage.html is
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <p>Simple text</p>
    <p><strong>Bold text</strong></p>
    <p><em>Italic text</em></p>
    <p align="center">Center text</p>
    <p><font color="#000099"><strong>Color text</strong></font></p>
    <p>image here : <img src="images/Pig.gif" width="121" height="129"></p>
    <p> </p>
    </body>
    </html>By pressing the Save button I can change the selected text.
    I don�t know the way to get and apply the format (size, color �) to only the selected text and display the selected image in real time in the EditorPane. Like if you press the Bold button, the selected text font will be change to bold.
    I would like to get or save the HTML code of the content of the EditorPane by pressing the Save button, How to make it?
    I can apply the formatting on the selected text in a JTextPane, but I don't know the way to save or export the content in HTML. By doing that it could fix my problem too.
    So any help to do that will be much appreciated.
    Thanks.

    Hi,
    Tks for your answer. That one I can do it. I would like to display the selected text in bold instead of adding the tag in the JEditorPane. If I get you right, you get the hole content of the JEditorPane and save it. How did you get it ? And before saving that in the database, did you fing the keysWord to convert the HTML tag in the corresponding entities ?
    Bellow you have a sample of code to make the formatting in the JTextPane.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.text.*;
    import javax.swing.text.Highlighter;
    import javax.swing.event.*;
    import java.util.*;
    import javax.swing.text.*;
    import javax.swing.text.BadLocationException;
    public class MonJTextPane extends JFrame implements CaretListener, ActionListener
              *     Attributs :
         private JTextPane monTextPane;
         private JLabel monLabel;
         private JButton monBouton;
         private StyleAide style; // class qui defini les effets de style de l'editeur
              *     Constructeur :
         public MonJTextPane ()
         {     super ("Aide");
              // construction du composant Texte
              this.style = new StyleAide (new StyleContext ());
              this.monTextPane = new JTextPane ();
              this.monTextPane.setDocument (style);
              this.monTextPane.addCaretListener (this);
              // construction de la fenetre :
              this.getContentPane ().setLayout (new BorderLayout ());
              this.setBounds (150,150,600,550);
              this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              this.monLabel = new JLabel ("Auncune ligne saisie...");
              this.monBouton = new JButton ("change de style");
              this.monBouton.addActionListener (this);
              JPanel panel = new JPanel ();
              panel.setLayout (new GridLayout (1,2));
              panel.add (monLabel);
              panel.add (monBouton);
              this.getContentPane ().add (panel, BorderLayout.SOUTH);
              this.getContentPane ().add (this.monTextPane, BorderLayout.CENTER);
              this.setVisible (true);
              *     Methodes :
         private int getCurrentLigne ()
         {     return ( this.style.getNumLigne (monTextPane.getCaretPosition ())+1 );
         public int getCurrentColonne ()
         {     return ( this.style.getNumColonne (monTextPane.getCaretPosition ())+1 );
              *     Methodes CaretListener:
         // ecoute les deplacements du curseur d'insertion
         public void caretUpdate(CaretEvent e)
         {     int debut = java.lang.Math.min (e.getDot (), e.getMark ());
              int fin   = java.lang.Math.max (e.getDot (), e.getMark ());
              this.monLabel.setText ("Ligne numero : "+ this.getCurrentLigne ()+" Colonne : "+this.getCurrentColonne ()+" (debut : "+debut+", fin : "+fin+")");
              *     Methodes ActionListener:
         public void actionPerformed (ActionEvent e)
         {     int start     = monTextPane.getSelectionStart();
              int end          = monTextPane.getSelectionEnd();
              int debut     = java.lang.Math.min (start, end);
              int fin          = java.lang.Math.max (start, end);
              int longueur= fin - debut;
              this.style.changeStyleSurligne (debut, longueur);
         // lance le tout ....
         public static void main (String argv [])
         {     new MonJTextPane ();
    // la Classe DefaultStyledDocument correspond a la classe utilise comme Model pour les
    // composant Texte evolue comme : JTextPane ou JEditorPane
    // en derivant de cette derniere nous pouvons donc redefinir les methodes d'insertion afin de personnalise
    // le style d'ecriture en fonction du texte et creer une methode permettant de modifier le style utilise pour
    // une partie de texte deja ecrite.
    class StyleAide extends DefaultStyledDocument
              *     Constructeur :
         public StyleAide (StyleContext styles)
         {     super (styles);
              initStyle (styles);
              *     Methodes :
         // redefini pour choisir l'effet de style a utiliser
         public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
         {     try
              {     // si le texte insere est egale a HELP le texte s'ecrit avec le style "styleOp"
                   if ( str.equals ("HELP") )
                   {     super.insertString (offs, str, getStyle ("styleOp"));
                   else // sinon le texte est ecrit avec le style "styleNormal"
                   {     super.insertString (offs, str, getStyle ("styleNormal"));
              catch (BadLocationException e)
              {     System.out.println ("Tuuuttt erreur Insere");
         // modifie le style d'ecriture d'un texte deja ecrit compris
         public void changeStyleSurligne (int positionDepart, int longueur)
         {     setCharacterAttributes (positionDepart, longueur, getStyle ("styleKeyWord"), true);
         // le Model d'un composant texte est enregistre sous form d'un arbre
         // cette methode permet de recuperer le noeud root de l'arbre
         private Element getRootElement ()
         {     return this.getDefaultRootElement ();
         // methode permettant d'obtenir la ligne correspondant a un offset donnee
         public int getNumLigne (int offset)
         {     Element eltR = getRootElement ();
              int numLigne = eltR.getElementIndex (offset);
              Element elt  = eltR.getElement (numLigne);
              if ( offset != elt.getEndOffset () )
              {     return numLigne;
              else
              {     if ( numLigne != 0 )
                   {     return numLigne+1;
              return 0;
         public int getNumColonne (int offset)
         {     Element eltR = getRootElement ();
              Element elt = eltR.getElement (eltR.getElementIndex (offset));
              int numColonne = offset-elt.getStartOffset ();
              return numColonne;
         // Defini les differents styles
         private static void initStyle (StyleContext styles)
         {     // definition du style pour le texte normal (brute)
              javax.swing.text.Style defaut = styles.getStyle (StyleContext.DEFAULT_STYLE);
              javax.swing.text.Style styleNormal = styles.addStyle("styleNormal", defaut);
              StyleConstants.setFontFamily (styleNormal, "Courier");
              StyleConstants.setFontSize (styleNormal, 11);
              StyleConstants.setForeground(styleNormal, Color.black);
              javax.swing.text.Style tmp = styles.addStyle("styleKeyWord", styleNormal);
              // Ajout de la couleur blue et du style gras pour les mots cle
              StyleConstants.setForeground(tmp, Color.blue);
              StyleConstants.setBold(tmp, true);
              tmp = styles.addStyle("styleOp", styleNormal);
              // Ajout de la couleur rouge pour le style des operateurs
              StyleConstants.setForeground(tmp, Color.red);
    }But it hard for me to convert it in the corresponding HTML document.
    Did you have and idea
    Tkks

  • 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.

  • Whats the difference between JEditorPane and JTextPan

    I was wondering where to use which? It looks like they have the same features, except that JEditorPane can load text from a URL.

    Hi,
    ofcourse it can, it is a subclass of JEditorPane and inherits its functionality :)
    greetings Marsian

  • Alternative to Hashtable? Got lots of data and "OutOfMemoryError"

    Hello,
    I am working on an application (CLDC1.1 and MIDP2.0, using NetBeans) and have to use a large look-up table with about 50 000 entries. During runtime the application is set to look up entries xxx times from the table, as fast as possible of course. I have used Hashtable for the table data (keys/value) until now, and distributed it all over several files / classes (singleton, static init) with a Hashtable for each class. Have not yet completely inserted the look-up table (about 30% percent left, and .jar size is 300 KB), but now I get the following error: Uncaught exception java/lang/OutOfMemoryError. All hashtables are initialized with a final size.
    I should have ca. 2 MB of RAM with the emulator Im using . Printing out freeMemory() from the Runtime I notice that the free mem number decreases fast, towards zero, and then it starts over again - decreasing from somewhere under 2 000 000 bytes down to 0. Not a wiz with debugging, but I guess I have to dive deeper into my garbage collection :)
    Is there a better way to store the keys (int) and values (int) of the look-up table? Like an associative array (pseudo): [["key"]=>[value]]
    Should I check out RMS (slow?), or some sorts of file handling? Or maybe a combination of Hashtables in memory and also RMS..?
    If someone could help with a hint or two, I would be very very thankful!
    Tib

    50 000 * (4 + 4) B = 400kB of uncompressed data. That's quite a lot for a MIDlet, but it's probably ok if the rest of your application is not so large. Hashtables need more than the size of the data to be effective, so I think an array of key-value pairs (sorted on the keys) would be best here, and of course using binary search when looking up the values.
    Or you can look at the range, distribution etc. of the keys, perhaps they will allow some optimization.

  • JEditorPane and JTree

    Hi,
    I have a tree that lists all objects and I want to do some kind of search feature. Results would be displayed in JEditorPane but I don't know anything about that. In JTree there is TreeSelectionListener (method valueChanged) and that has the functionality I need to have on JEditorPane but I don't know if this is possible?
    Any advices please?

    Hi,
    I have a tree that lists all objects and I want to do some kind of search feature. Results would be displayed in JEditorPane but I don't know anything about that. In JTree there is TreeSelectionListener (method valueChanged) and that has the functionality I need to have on JEditorPane but I don't know if this is possible?
    Any advices please?

  • JEditorPane and HTML

    I have this html file on my C drive and I want to display it in a JEditorPane. THe problem is that I always get this malformed URL exception. I've done this before, but right now I can't seem to figure out whats happening. Any help as to the syntax and how I can go about doing this. Thanks

    It would help if you can post the URL you're using.

  • JEditorPane and copy/paste

    Hello,
    I've got an applet with an editable JEditorPane.
    I can make a copy/paste in the editor from any application outside the applet and from the applet itself. But with Word under windows, the paste method tries to insert html rendered by word and it can't do that.
    Then I extended the TransferHandler class to make my own transfer handler, just to copy the text from a word selection. But doing that I can't do any copy/paste from the editor to the editor .... I don't understand ...
    public class MyTransferHandler extends TransferHandler {
         public boolean importData(JComponent comp, Transferable t)
         try {
              if (t.isDataFlavorSupported(new DataFlavor("text/plain;class=java.io.InputStream;charset=ISO-8859-1"))) {
              System.out.println("Flavor text/plain charset ISO-8859-1");
              InputStream data = (InputStream) t.getTransferData(new DataFlavor("text/plain;class=java.io.InputStream;charset=ISO-8859-1"));
              InputStreamReader isReader = new InputStreamReader(data);
              StringWriter strw = new StringWriter();
              int c;
              while ((c = isReader.read()) != -1) {
                   strw.write(c);
              //          System.out.println(strw.toString());
              SimpleHtmlWriter.this.editor.replaceSelection(strw.toString());
              } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
              System.out.println("Flavor string");
              String data = (String) t.getTransferData(DataFlavor.stringFlavor);
              //          System.out.println(data);
              SimpleHtmlWriter.this.editor.replaceSelection(data);
              return true;
         } catch (Exception e) {     
              e.printStackTrace();
              return false;
    Thanks a lot ...

    Or, you could use the cut, copy, paste methods of the JEditorPane.
    You can also use the DefaultEditorKit.CopyAction to create an Action to use on a button or menu item.

  • 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.

  • Dynamic Proxy and OutOfMemoryError

    I ran into this problem before when working with Proxied objects.
    I am integrating iBatis into my framework and using Dynamic Proxies to allow a developer to pass in a DAO interface and the Dynamic Proxy will retrieve the correct iBatis SQL Map and run it according to the DAO interface method. Some of these DAO methods take parameters that are lists with 100,000s of records. When I run my batch process using Dynamic Proxies, I get OutOfMemoryError in WebLogic. When I remove the Dynamic Proxy and create a simple implementation for my DAO that I use instead of Proxying it, I get no error and my process runs fine.
    Any thoughts? Does sending huge amounts of data through a Proxy or doing quite a bit of activity inside a Proxied object cause OutOfMemoryErrors?
    Thanks,
    -jay blanton

    Check you don't have an infinite loop or recursion which is wrapping Proxies in Proxies in Proxies...

  • JEditorPane and scrollbars

    Hi there,
    I'm using the JEditorPane to display some simple html and css - in fact all it is a div of a fixed width containing an abitary amount of text. What I want to do is calculate the height of the div in pixels. In a browser this is easy enough, you just use javascript to look up the div's clientHeight property, but for the life of me I can't workout how to do this using the Swing api in the JEditorPane. It must know how high the whole rendered html is as it knows when to add the vertical scroll bar
    As an alternative approach i though i could just set the size of the containing JFrame and then check to see if a vertical scroll bar had appeared, if it had then I would know that the height of the text in the div exceeded the hight of the frame, but the
    scrollPane.getVerticalScrollBar().isVisible() method always seems to return false...
    If anyone has any idea how to do this (or rather, what i'm doing wrong) it would be appreciated.
    Thanks
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.IOException;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.UIManager;
    public class TextPane extends JFrame {
           private  JEditorPane pane;
           private   JScrollPane scrollPane;       
         public TextPane(){
             pane = new JEditorPane();
             pane.setEditable(true); // Read-only
             try{
                  pane.setPage("html-file-that-contains-enough-text-to-cause-the-scroll-bar-to-appear.html");
             catch(IOException e){
                  throw new RuntimeException(e);
             scrollPane = new JScrollPane(pane,
                       JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
             getContentPane().add(scrollPane);
           public static void main(String[] args) {
                  try {
                      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                  } catch (Exception evt) {}
                  TextPane f = new TextPane();
                  f.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent evt) {
                      System.exit(0);
                  f.setSize(400, 300);
                  f.setVisible(true);
                  if(f.scrollPane.getVerticalScrollBar().isVisible()){
                     System.out.println("Scroll Bar is showing");
                 else{
                     System.out.println("Scroll Bar is not showing");
    }

    If the editorpane is visible you can use getPreferredSize(). The srollpane also relies on this method to determine when to show scrollbars.
    public class DivHeight {
        public static void main(String[] args) throws Exception {
            final JEditorPane pane = new JEditorPane();
            pane.setBorder(null);
            pane.setContentType("text/html");
            pane.setText("<html><div style='margin: 0px; padding: 0px; width: 200px; background-color: #DDDDDD;'>Bla bla bla bla bla saf jölasj dfölasjdf ölasjdf ölasjdfölkasjdf löjkasdf löjasdlöfk jaslökdfklö asjdf öasjdfölk asjdlfkö jaslökdj löaskdjafö lkjasdlöfk jaslökdfj ölaskjsdlköf jaslökfjlökasdjf lköasjdf lköasdjflökjsadflkjdölaksdjf ölkasdjfölk Bla bla bla bla bla saf jölasj dfölasjdf ölasjdf ölasjdfölkasjdf löjkasdf löjasdlöfk jaslökdfklö asjdf öasjdfölk asjdlfkö jaslökdj löaskdjafö lkjasdlöfk jaslökdfj ölaskjsdlköf jaslökfjlökasdjf lköasjdf lköasdjflökjsadflkjdölaksdjf ölkasdjfölk Bla bla bla bla bla saf jölasj dfölasjdf ölasjdf ölasjdfölkasjdf löjkasdf löjasdlöfk jaslökdfklö asjdf öasjdfölk asjdlfkö jaslökdj löaskdjafö lkjasdlöfk jaslökdfj ölaskjsdlköf jaslökfjlökasdjf lköasjdf lköasdjflökjsadflkjdölaksdjf ölkasdjfölk </div></html>");
            JButton button = new JButton("print size");
            button.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.out.println(pane.getPreferredSize());
            JFrame frame = new JFrame();
            frame.getContentPane().add(button, BorderLayout.NORTH);
            frame.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 300);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    }

  • Utilisation of XMLInputStream and OutOfMemoryError (WLS 8.1 SP5)

    Hello,
    Did somebody use weblogic.xml.stream.XMLInputStream to read/parse a large XML file?
    If I understand it well, this class uses SAX to parse the files, so it must be stateless and it must not consume a lot of memory.
    However, when I try to read a 15 Mb XML file, using the following code :
    XMLInputStream matchingStream = XMLInputStreamFactory.newInstance().newInputStream(pFile);
    while (matchingStream.hasNext()) {
    XMLEvent event = matchingStream.next();
    , memory's being consumed quickly and I get OutOfMemoryError when the java process' memory exceedes 74 Mb.
    Can you approve/disapprove my utilisation of this class ?
    Thanks in advance

    I would normally suggest raising the issue with support, but I recall hearing that 8.1 is nearing the end of its support cycle, so I'm not sure that's an option for you. Other options:
    - try upgrading to a newer SP, or better yet, a new version of WebLogic
    - try changing to synchronous forwarding
    - examine thread dumps from when the bridge appears to be stalled
    - post the exception that bridge is throwing when it tries to connect
    - try patching MQ (the problem could be on the MQ side, and perhaps an older version of the bridge may not be fully capable of handling all of MQs minor quirks)
    - write a program to (A) detect inactivity on the src destination, and (B) somehow restart the bridge and/or all of WL when this occurs
    Tom

  • 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 and HyperlinkListener Problems

    Here's my code:
    public class WizardHelpScreen extends JFrame implements HyperlinkListener {
    private Image theIcon = new ImageIcon(getClass().getResource("icon.gif")).getImage();
    private JEditorPane helpPane;
    private JScrollPane helpScrollPane;
    public WizardHelpScreen() {
         super("Help Documents");
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            setIconImage(theIcon);       
            startHelp();
    public void startHelp() {
         helpPane = new JEditorPane();
         helpScrollPane = new JScrollPane(helpPane);
         helpPane.setEditable(false);
                helpPane.addHyperlinkListener(this);
                getContentPane().add(helpPane);
               setLocation(230,230);
               setPreferredSize(new Dimension(640,480));
               pack();
            setVisible(true);
                try {
                      helpPane.setPage("file:///c:/japps/HelpTestTwo.html");
             } catch(IOException ex) {
                       JOptionPane.showMessageDialog(null,"Unable to load helpfile.","Error",JOptionPane.ERROR_MESSAGE);     
                       helpPane.setText("Error. Unable to load help file. Please reinstall the application or contact support.");
    public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                 Document doc = helpPane.getDocument();
                    try {
                        URL url = e.getURL();
                        helpPane.setPage(url);                    
                    } catch (IOException io) {
                     JOptionPane.showMessageDialog(null, "Can't follow link","Invalid Input",JOptionPane.ERROR_MESSAGE);
                     helpPane.setDocument(doc);
    }It opens the html document just fine, and even activates the hyperlink in the first html document. The problem is in the second document that is shown after clicking the link in the first document, the links in the second document don't work anymore. It's like the HyperlinkListener deactivated or something. What am I doing wrong?

    Nevermind, there was a typo in my HTML that caused the problem.

Maybe you are looking for

  • Problems in Installation of E-Business Suite 11.5.10 on Redhat Linux EL

    Hi, I am installing Oracle 11i 11.5.10.2 on linux ES 3 Kernel version 2.4.21-4. I am done with the staging but while installing Rapidwiz i am getting following error Rapid Install Wizard is validating your file system...... Rapid Install Wizard will

  • IPhoto 6 Missing Pictures and Bigger Library

    Please help me if you can, I'm feeling down ... While I was using iPhoto 5 I discovered there were many missing pictures. Thumbnails were there, but the full-sized images had disappeared. I tracked down most of the originals, and imported them into i

  • Deploying ADF Faces (JDev 10.1.3) to Application server 10gR2 (10.1.2)

    Is it possible to deploy a Toplink/sessionEJBs/Data controls/ADF Faces app (written in jDev10.1.3) to Oracle Application Server (10.1.2)? I'm using Application Developers Framework Developer's guide adfdevguide.pdf, which says that you can. However i

  • Codepage conversion

    Dears,    we could input codepage in Function GUI_DOWNLOAD, and the conversion is done .    Now i want to do the conversion in my program, is there any funnctions to be called or other ways /   Ths.

  • How do I maketotally custom e-mails that everyone can see without downloadi

    I run a website made on iweb. It is http://Ostyn-Newman.com I send out periodic annoucements to several hundred clients announcing new products on the site. I currently use IPhoto to process photos and send them via e-mail from that application. They