Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:Alin,
I took a quick glance at your code, and being in a different language always and no headers on your Frame objects puts a damper on things, but this line is making an orphan. You might take a look there to start off.
Les
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:Alin,
If I understand correctly you are trying to display something in the second form. The problem you are running into, I think, is that the form you want to display something in is an orphan. You do not have a reference to it, so you cannot display something in it. I think you have a reference to an object of that type, but not to the actual form that is being displayed. When you do a "new MyForm.setVisible(true)" you get a new form, and ALL of the components are new inside that form, so it is orphaned--you have no easy way of reaching that form to add anything to it.
If that is not the case, then you need to do some debug coding. First off, put a title on all of your forms, and make the title distinct for the location it is created and displayed. That way you can tell exactly what form you have being displayed. Once you know that, then you will know what is happening or be more able to further debug.
I discount the idea of blocking the EDT causing the form not to display, if the EDT was blocked, then he form would pop up sluggishly and res in sluggishly and may be unresponsive to any actions done upon the frame. I look more for that idea that you are updating an instance of the form, but what is being displayed is an new orphan instance--independent of the instance you update.
Les
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:Alin,
You have "lista.setModel(model);" once in the declaration area of MainGui and once where you deserialize, open, but I don't see any where in that Class where lista is defined or where it is initially instantiated. Be aware, that when you deserialize, load, an object that is a new object and not the one that was loaded, so none of your references to it will be correct. Nor can you expect it to take back up where the old one left off. You either have to change a instance variable reference to it, or return a reference to the new object back out of your method. It looks like you are trying to change a instance variable reference, but once again, I don't see any instantiation, or declaration as far as that goes, of "lista" in the object where it is being used.
Les
Alin Andrei wrote:
Question: After I Press on the "Add" button from the adaugaPers.java class, it also creates a new LinkedList? When I run the app, add the persons then serialize and If I don't close the application, the "Add" button adds elements to the same linkedlist object but once I close the application it creates a brand new object. How can I avoid this?
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Les Morgan wrote:You shouldn't avoid creating a new Linked List when you start, that would probably be a little counter productive, but when you deserialize, you need to replace the existing object with the deserialized objects. That means that you need a reference in the deserializing, loading, routine or you need to return the object to replace the reference with the deserialized object.
So... you have to fix it in the deserializing routine or return the object reference to the deserialized object.
Alin Andrei wrote:
Question: After I Press on the "Add" button from the adaugaPers.java class, it also creates a new LinkedList? When I run the app, add the persons then serialize and If I don't close the application, the "Add" button adds elements to the same linkedlist object but once I close the application it creates a brand new object. How can I avoid this?
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Consider Paul's rocket mass heater. |