Results 1 to 3 of 3
  1. #1
    nadia is offline Member
    Join Date
    Dec 2008
    Posts
    13
    Rep Power
    0

    Default StyledDocument for JTextPane

    HI,,
    i am making a text editor..I insert an image in JTextPane... then save file.While reopening i see that my .GIF images (animating) are not animating why is this so? ANY solution. Basically i save StyledDocument as follows:
    try {
    FileOutputStream fos = new FileOutputStream ("e:\\doc.ser");
    ObjectOutputStream oos = new ObjectOutputStream (fos);
    oos.writeObject (doc);//doc is the styled document set for this textpane
    oos.flush();
    oos.close();
    statusInfo.setText ("Saved to disk");
    } catch (IOException e) {
    statusInfo.setText ("Unable to save");
    e.printStackTrace();
    }
    File is opened as Follows:
    try {
    FileInputStream fis = new FileInputStream ("e:\\doc.ser");
    ObjectInputStream ois = new ObjectInputStream (fis);
    doc = (StyledDocument)ois.readObject();
    ois.close();
    pane.setStyledDocument (doc);
    validate();
    statusInfo.setText ("Reloaded from disk");
    } catch (Exception e) {
    statusInfo.setText ("Unable to reload");
    e.printStackTrace();
    }


    please smbdy help....
    Last edited by nadia; 12-27-2008 at 04:48 PM. Reason: some neccessary comments were left

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    10

    Default

    You may have to deconstruct the animated gif images and data to save and then restore. These links may be helpful:
    reply 17 and reply 1.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,370
    Blog Entries
    1
    Rep Power
    21

    Default

    Please use code tags next time to wrap your code segments. Unformated codes are hard to read.

    XML Code:
        [CODE]
            // Place your code here
        [/CODE]

Similar Threads

  1. GetIcon from jTextPane
    By Gudradain in forum AWT / Swing
    Replies: 4
    Last Post: 11-26-2008, 04:26 AM
  2. JTextPane with servlets
    By kinabaloo in forum Advanced Java
    Replies: 2
    Last Post: 07-11-2008, 06:32 AM
  3. JTextPane Styles Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:48 PM
  4. [SOLVED] hyperlinks in JTextPane
    By olbion in forum New To Java
    Replies: 4
    Last Post: 05-05-2008, 03:28 AM
  5. Transparent JTextPane
    By Ada in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2007, 09:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •