Hello.
I have search my app for all classes to implement java.io.Serializable. I think that
the needed classes are covered.I create and serialize JInternalFrames. When I re-open a JInternalFrame some of the JMenuItems do not do thier job. Also when I right click the Tabs on the JTabbedPane to bring up the popup menu there is no indication that there was a event. (no popup menu).
The JInternalFrames have InternalFrameListeners and the JTabbedPanes have a MouseAdapter
added when they are built. The originals work fine but if closed.The(serialized)copys don't. Is there some info on this? I tried Key words simialar to this post title.
ceyesuma -4 Posting Pro
Hello.
I have the methods used to serialize and deserialize but the final JInternalFrame
re opened does not have the menu or popup menu that the original has.
Is there more I have to do to save JInternalFrames and there Actions?
Thanks
Serialize
public boolean serializeFrame(JInternalFrame frame) throws FileNotFoundException, ProfileException, LoginException,
SQLException, javax.security.auth.login.LoginException, ClassNotFoundException, InstantiationException,
IllegalAccessException {
System.out.println(key);
String M = (" --> public boolean serializeFrame("+frame.getTitle()+c+frame+") var: frame.getTitle() :name : path
:<-- \n");
System.out.println(M);
bSaved = true;
setFrame(frame);
setName(frame.getTitle());
String systemDir = SYSTEMFOLDERPATH + File.separator + name + EXT;
setFolderLocation(systemDir);
try {
FileOutputStream fo = new FileOutputStream(systemDir);
ObjectOutputStream oo = new ObjectOutputStream(fo);
oo.writeObject(frame);
oo.flush();
oo.close();
} catch (IOException e) {
bSaved = false;
System.out.println("Error- " + e.toString());
}
return bSaved;
}
deserialize Frame
public void allowOpeningOfNoteFrame(String name,String systemDir) throws FileNotFoundException, IOException,
ProfileException, LoginException, SQLException, model.err.LoginException, UnknownUserNameException,
IncorrectPasswordException, SuccessfullTargetFoldersCreation, ClassNotFoundException, InstantiationException,
IllegalAccessException, NoTargetFoldersException {
System.out.println(key);
String M = (" --> in public void allowOpeningOfNoteFrame("+name+c+systemDir+") var: xxxxxxxxx : xxxxxxxx<-- \n");
System.out.println(M);
try {
FileInputStream fis=new FileInputStream(systemDir);
ObjectInputStream ois= new ObjectInputStream(fis);
Object obj= (JInternalFrame) ois.readObject();
if(obj instanceof Object){
System.out.println(C+M+AND+" : if(obj instanceof Object) : \n ");
System.out.println(C+M+AND+obj.getClass()+c+obj+": obj.getClass()+c+obj : \n ");
}
if(obj instanceof JInternalFrame){
System.out.println(C+M+AND+obj.getClass()+": obj.getClass() : if(obj instanceof JInternalFrame){ : \n");
noteFrame=(JInternalFrame) obj;
System.out.println(C+M+AND+noteFrame.getTitle()+c+noteFrame+": noteFrame.getTitle(),noteFrame : \n");
}
fis.close();
} catch (IOException e) {
System.out.println("Error - " + e.toString());
}
System.out.println(C+M+AND+": caller \n--->: NotesAction.openSelectedFrame("+noteFrame.getTitle()+c+name+c+noteFrame
+c+systemDir+") : var: oteFrame.getTitle()+c+name+c+noteFrames <-----\n");
NotesAction.openSelectedFrame(noteFrame,name,systemDir);
System.out.println(key);
}
public void allowOpeningOfNoteFrame output
if(obj instanceof Object){
--> in public void allowOpeningOfNoteFrame(frame1 , C:\Users\Steves_\.targetFolders\admin_\admin\Note Folder
\SystemDataFolder\frame1.ser) var: xxxxxxxxx : xxxxxxxx<--
public class OpenNoteFrameFile extends CreateSystemStartFolders implements java.io.Serializable{:
--> in public void allowOpeningOfNoteFrame(frame1 , C:\Users\Steves_\.targetFolders\admin_\admin\Note Folder
\SystemDataFolder\frame1.ser) var: xxxxxxxxx : xxxxxxxx<--
: class view.SchoolJDesktopPane$InternalFrameNotes , view.SchoolJDesktopPane$InternalFrameNotes
[,0,100,700x250,invalid,layout=javax.swing.plaf.basic.BasicInternalFrameUI
$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.metal.MetalBorders
$InternalFrameBorder@1594a88,flags=264,maximumSize=,minimumSize=,preferredSize=,closable=true,defaultCloseOperation=DISPOSE_O
N_CLOSE,desktopIcon=javax.swing.JInternalFrame$JDesktopIcon
[,0,0,160x31,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource
$CompoundBorderUIResource@11a0d35,flags=8,maximumSize=,minimumSize=,preferredSize=],frameIcon=sun.swing.ImageIconUIResource@8
c7be5,iconable=true,isClosed=false,isIcon=false,isMaximum=false,isSelected=false,maximizable=true,opened=true,resizable=true,
rootPane=javax.swing.JRootPane[,5,28,690x217,invalid,layout=javax.swing.JRootPane
$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled
=true,title=frame1]: obj.getClass()+c+obj :
stanceof Object) :
public void allowOpeningOfNoteFrame output
if(obj instanceof JInternalFrame){
: class view.SchoolJDesktopPane$InternalFrameNotes: obj.getClass() ::
: frame1 , view.SchoolJDesktopPane$InternalFrameNotes
[,0,100,700x250,invalid,layout=javax.swing.plaf.basic.BasicInternalFrameUI
$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.metal.MetalBorders
$InternalFrameBorder@1594a88,flags=264,maximumSize=,minimumSize=,preferredSize=,closable=true,defaultCloseOperation=DISPOSE_O
N_CLOSE,desktopIcon=javax.swing.JInternalFrame$JDesktopIcon
[,0,0,160x31,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource
$CompoundBorderUIResource@11a0d35,flags=8,maximumSize=,minimumSize=,preferredSize=],frameIcon=sun.swing.ImageIconUIResource@8
c7be5,iconable=true,isClosed=false,isIcon=false,isMaximum=false,isSelected=false,maximizable=true,opened=true,resizable=true,
rootPane=javax.swing.JRootPane[,5,28,690x217,invalid,layout=javax.swing.JRootPane
$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled
=true,title=frame1]: noteFrame.getTitle(),noteFrame :
open the frame
public static void openSelectedFrame(JInternalFrame noteFrame,String name,String systemDir) throws ClassNotFoundException {
System.out.println(key);
String M = (" --> in public static void openSelectedFrame("+noteFrame+c+name+c+systemDir+") {var: (Object obj,String
name,String systemDir):\n");
System.out.println(M);
System.out.println(C+M+AND+": caller \n--->: NotesAction.openSelectedFrame("+noteFrame.getTitle()+c+name+c+noteFrame
+") : var: oteFrame.getTitle()+c+name+c+noteFrames <-----\n");
SchoolJDesktopPane.jdp.add(noteFrame);
//f.addInternalFrameListener((InternalFrameListener) f);
noteFrame.moveToFront();
SchoolJDesktopPane.setFrame(noteFrame);
SchoolJDesktopPane.validateAndPaintDesktop();
System.out.println(key);
}
Are these supposed to be the same or something?
saved frame
CLASS
public class SaveNoteFrame extends CreateSystemStartFolders implements java.io.Serializable{ { {:
--> in public void firstInstance(JInternalFrame frame)(frame1 , view.SchoolJDesktopPane$InternalFrameNotes
[,0,100,700x250,invalid,layout=javax.swing.plaf.basic.BasicInternalFrameUI
$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.metal.MetalBorders
$InternalFrameBorder@1594a88,flags=264,maximumSize=,minimumSize=,preferredSize=,closable=true,defaultCloseOperation=DISPOSE_O
N_CLOSE,desktopIcon=javax.swing.JInternalFrame$JDesktopIcon
[,0,0,160x31,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource
$CompoundBorderUIResource@11a0d35,flags=8,maximumSize=,minimumSize=,preferredSize=],frameIcon=sun.swing.ImageIconUIResource@8
c7be5,iconable=true,isClosed=false,isIcon=false,isMaximum=false,isSelected=false,maximizable=true,opened=true,resizable=true,
rootPane=javax.swing.JRootPane[,5,28,690x217,layout=javax.swing.JRootPane
$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled
=true,title=frame1]) var: frame.getTitle() :name : path :<--
: true: bSaved fileSystemDir :
frame to open
CLASS
public class NotesAction extends AbstractAction implements Runnable,java.io.Serializable {:
--> in public static void openSelectedFrame(view.SchoolJDesktopPane$InternalFrameNotes
[,0,100,700x250,invalid,layout=javax.swing.plaf.basic.BasicInternalFrameUI
$Handler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.metal.MetalBorders
$InternalFrameBorder@1594a88,flags=264,maximumSize=,minimumSize=,preferredSize=,closable=true,defaultCloseOperation=DISPOSE_O
N_CLOSE,desktopIcon=javax.swing.JInternalFrame$JDesktopIcon
[,0,0,160x31,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource
$CompoundBorderUIResource@11a0d35,flags=8,maximumSize=,minimumSize=,preferredSize=],frameIcon=sun.swing.ImageIconUIResource@8
c7be5,iconable=true,isClosed=false,isIcon=false,isMaximum=false,isSelected=false,maximizable=true,opened=true,resizable=true,
rootPane=javax.swing.JRootPane[,5,28,690x217,invalid,layout=javax.swing.JRootPane
$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled
=true,title=frame1] , frame1 , C:\Users\Steves_\.targetFolders\admin_\admin\Note Folder\SystemDataFolder\frame1.ser) {var:
(Object obj,String name,String systemDir):
: : caller
Edited by ceyesuma because: word wrap
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.