This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Serialization??" Watch "Serialization??" New topic
Author

Serialization??

Prionsios Mac Giollacom�in
Greenhorn

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
Greenhorn

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
Greenhorn

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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Serialization??
 
Similar Threads
SoDuko puzzle
nested loop??
loop?
Load files
JFormattedTextField