Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:00:01+00:00 2026-05-23T16:00:01+00:00

I have Swing application which manipulate shapes. In my toolbar I have a zoom

  • 0

I have Swing application which manipulate shapes. In my toolbar I have a zoom function that the user activate by clicking on a button, then the cursor of the mouse changes to a magnifier which is an image.
My problem is actually the cursor, for some raisons, when I set the cursor on the panel displaying the shapes, I can’t save my model and I get the java.io.NotSerializableException: sun.awt.image.ToolkitImage exception.

My model

public class Document implements IDocObservable,Serializable{

...

public void updateCursor() {
    Iterator<IDocObserver> iter = docObservers.iterator();
    while (iter.hasNext()) {
        iter.next().docCursorChanged();
    }
}
... 

}

The action

public class ZoomInAction extends AbstractAction {


public void actionPerformed(ActionEvent arg0) {
    ...
    Application.getInstance().getActiveDocument().updateCursor();
}

}

The display Panel (note : if I comment the setCursor(..) line, I’am able to save )

public class Window extends JPanel implements IDocObserver{
...

public void paint(Graphics g){          
    //drawing the differents shapes
}

@Override

public void docCursorChanged() {        
    setCursor(Utile.getZoomInCursor();
    }
}

}

The class that provide the cursor

public class Utile {

private static Image zoomIn = toolkit.getImage(Utile.class.getResource("/images/zoomin_mouse.png"));
...

public static Cursor getZoomInCursor() {        
    return  toolkit.createCustomCursor(zoomIn, hotSpot, ""); 
}

}

The writing of the object is a standard Java methode with outStream.writeObject(doc);

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:00:02+00:00Added an answer on May 23, 2026 at 4:00 pm

    You aren’t just serializing a model, you are serializing a list of IDocObservers, which includes Window extends JPanel implements IDocObserver. IOW you are serializing a JPanel. Don’t do that: see the warning at the top of the Javadoc. You don’t need to save the observers along with the observable, surely: can’t you make that list transient?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Swing application that connect directly to MySql Database for user authentication.
I have a Java swing application with a button that produces a popup window
I have swing application in which there is MS excel like functionality. User can
I have a Java application which is used to start a Swing user interface.
I have a java swing application which has a form that I populate by
I have a calculator application in java swing, which is working properly with mouse
I have made a swings application but there is one problem in that which
I have a swing application that uses some datas coming from an external mysql
i have a swing application that i would like to run on os x
I have a Swing application that I would like to convert from spaghetti to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.