File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Serialization?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Serialization??" Watch "Serialization??" New topic


Prionsios Mac Giollacom�in

Joined: Jan 16, 2006
Posts: 12
Im new to java programming. I have set up a sudoku GUI. I have 81 JComboBoxes in a 9x9 array. The main GUI is a JFrame with 9 JPanels added to it. Each panel holds 9 instances of JComboBox, which are populated with the numbers 1-to-9.

Basically, I want to be able to input a sudoku puzzle and then save it. Then if I come back later I should be able to open it up from where it was saved.

This is probably simple, but it is confusing me. By using serialization can I read what Items have been selected and save it so that it will open up exactly the same later? Each ComboBox knows its coordinates.

I would also like to remove the itemlisteners from the comboboxes that have been inputed, so that these given sudoku values cannot be tampered with.

Any help or advice would be appreciated.
Amol Fuke
Ranch Hand

Joined: Apr 08, 2005
Posts: 129
Yes.You can do it with the help of Serialization.Make one data object of all these values.(dataobject I mean setter,getter) and save it in database when user exists.You can save this object in BLOB column of database.
When user comes next time,read the BLOB data ,type cast into your data object and set it in the GUI.

Let me know if you face any problem.

"There are no mistakes, only lessons"
Prionsios Mac Giollacom�in

Joined: Jan 16, 2006
Posts: 12
Im not really sure what you mean.

Ive a toString() method which prints out whats selected in each instance of JComboBox( using the itemStateChanged() method of JComboBox). How would I read this into a BLOB and remove the itemListener or itemStateChanged event from the JComboBox object?

Should I send the ObjectOutputStream to a certain file?
Prionsios Mac Giollacom�in

Joined: Jan 16, 2006
Posts: 12
I suppose the first step is to set up a JButton "Set", which when pressed should, input the information into a BLOB and simultaneously deactivate the itemListners on the respective JComboBoxes........but not sure how!
I agree. Here's the link:
subject: Serialization??
It's not a secret anymore!