Reputation: 88
I've been creating a fairly complex applet using JFrames extending other JFrames on NetBeans and I'm having issues with accessing data from previous JFrame screens. Looking at the diagram below:
My applet opens with a main screen (MainScreen
) with a button for accessing a new page for editing .xls pages (EditScore
). This page extends a kind of skeleton JFrame (MenuSkeleton
) which is a general form for EditScore
and other pages (call them Edit1
and Edit2
) which can be accessed through MainScreen
. I use MenuSkeleton
because both of these pages are only slightly different from each other.
MenuSkeleton
opens a file chooser in EditScore
which allows users to choose a .xls page to edit and saves this page's name in the integer xlsName
(saved in MenuSkeleton
). So xlsName
is initialized as an empty String in MenuSkeleton
but given a new value in EditScore
.
EditScore
has a button which opens the .xls editor (EditingWindow
). EditingWindow
extends WindowSkeleton
which extends MenuSkeleton
because:
-I need to access xlsName
in WindowSkeleton
-WindowSkeleton
can't extend EditScore
because sometimes it is called through Edit1
and Edit2
and doesn't even open EditScore
.
My problem is with accessing xlsName.
I can access xlsName
just fine in MenuSkeleton and in EditScore, but once I try to access it in WindowSkeleton
or EditingWindow
, it's null. I'm guessing this means a new instance of MenuSkeleton
is being created when I extend it in WindowSkeleton
. Is there a way for me to access the value xlsName
is given in editFolder
?
Thanks for reading through this ridiculous question! I'm sorry it's so long and confusing - I'll add/modify based on any suggestions I receive.
Upvotes: 0
Views: 58
Reputation: 84
As far as I understand EditingWindow
and EditScore
both extend MenuSkeleton
. But EditingWindow
also extends WindowSkeleton
. Try bypassing WindowSkeleton
and extend EditingWindow
directly from MenuSkeleton
. Extending from two classes one of which is already a subclass causes problems. Hope this helps.
Upvotes: 1