• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tooltips lost when saving object

 
Wray Ferrell
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a program that needs to save information periodically (ie a forced user backup). The object being saved has a JCheckBox on which I called setToolTipText. The problem is when the object is saved the tool tip text is lost. However if I quit the program and read in the save file the tool tip text is restored.

I looked in the Sun bug database and could not find a match. So is this a new bug for Java 1.6 or is there some special function I need to add to continuing using an object after it was saved.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how are you "saving" the checkbox? Serialization?
 
Wray Ferrell
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
So how are you "saving" the checkbox? Serialization?


Sorry, I should have been more specific. Yes, the object is marked Serializable. The code to save the data is:

FileOutputStream fileStream = new FileOutputStream("CivCalc.sav" + turn);
ObjectOutputStream os = new ObjectOutputStream(fileStream);
os.writeObject(CivCalculator.getPlayerList());
os.close();
turn++;

PlayerList is an arrayList of player object which is below:

public class player implements Comparable<player>, Serializable {
// Per object data
private ArrayList<card> cardList = new ArrayList<card>();
<snip>

abstract public class card implements Serializable {
// Common card data
cardNames cardName;
int originalCost;
int currentCost;
JCheckBox checkBox;
<snip>

public class agriculture extends card {

public agriculture() {
cardName = cardNames.Agriculture;
originalCost = currentCost = 110;
bought = false;
checkBox = new JCheckBox();
<snip>

It is the checkboxes in the classes that extend card that are
losing the tooltips.

Thanks, Wray
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!