Click here to Skip to main content
15,903,203 members
Home / Discussions / Java
   

Java

 
AnswerRe: screen shairing application Pin
Nagy Vilmos3-Dec-09 23:54
professionalNagy Vilmos3-Dec-09 23:54 
AnswerRe: screen shairing application Pin
Arun Reginald Zaheeruddin1-Mar-10 0:05
Arun Reginald Zaheeruddin1-Mar-10 0:05 
QuestionGWT https Pin
sangeethanarayan3-Dec-09 17:36
sangeethanarayan3-Dec-09 17:36 
AnswerRe: GWT https Pin
Nagy Vilmos4-Dec-09 0:24
professionalNagy Vilmos4-Dec-09 0:24 
GeneralRe: GWT https Pin
sangeethanarayan4-Dec-09 5:02
sangeethanarayan4-Dec-09 5:02 
GeneralRe: GWT https Pin
Nagy Vilmos4-Dec-09 5:34
professionalNagy Vilmos4-Dec-09 5:34 
Question[Solved] Access Problem with different classes and instances [modified] Pin
TheRainer3-Dec-09 16:13
TheRainer3-Dec-09 16:13 
AnswerRe: Access Problem with different classes and instances Pin
Cedric Moonen3-Dec-09 23:40
Cedric Moonen3-Dec-09 23:40 
Your question is really vague but ir really looks like you are a bit confused about how to use classes properly.


TheRainer wrote:
Is there a way to reach an instance from another instance?


Yes, as long as the first object has access to the object it wants to use.

As far as I understood, you have a GoalTrackerStorage class which contains your data, and then you have other "GUI" classes that have to display the content of this class. Am I right ?
Well, the easy solution is to simply pass the instance of GoalTrackerStorage to your different classes that need to show it.


TheRainer wrote:
GoalTrackerStorage GoalTrackerStorage = new GoalTrackerStorage();
GoalTrackerTabFolder GoalTrackerTabFolder = new GoalTrackerTabFolder();
GoalTrackerTable GoalTrackerTable = new GoalTrackerTable();


By the way, this is wrong: you cannot have a class instance with the same name as a class. I suggest you use the standard notation in java: all the variables starts with a lowercase letter. So, you would write this instead:

GoalTrackerStorage goalTrackerStorage = new GoalTrackerStorage();
GoalTrackerTabFolder goalTrackerTabFolder = new GoalTrackerTabFolder();
GoalTrackerTable goalTrackerTable = new GoalTrackerTable();


So, in this case, the solution to your problem is to simply pass the goalTrackerStorage instance to the constructors of the different classes:

GoalTrackerStorage goalTrackerStorage = new GoalTrackerStorage();
GoalTrackerTabFolder goalTrackerTabFolder = new GoalTrackerTabFolder(goalTrackerStorage );
GoalTrackerTable goalTrackerTable = new GoalTrackerTable(goalTrackerStorage )


(Of course, you will need to supply a corresponding constructor to those classes).

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

QuestionRe: Access Problem with different classes and instances [modified] Pin
TheRainer11-Dec-09 4:33
TheRainer11-Dec-09 4:33 
AnswerRe: Access Problem with different classes and instances Pin
Cedric Moonen11-Dec-09 4:43
Cedric Moonen11-Dec-09 4:43 
AnswerRe: Access Problem with different classes and instances Pin
TheRainer11-Dec-09 7:05
TheRainer11-Dec-09 7:05 
QuestionBack Button on popup window doesn't work in IE Pin
sam#2-Dec-09 0:46
sam#2-Dec-09 0:46 
AnswerRe: Back Button on popup window doesn't work in IE Pin
David Skelly2-Dec-09 0:55
David Skelly2-Dec-09 0:55 
QuestionOutput error for Avl tree Pin
vtsmokey881-Dec-09 19:14
vtsmokey881-Dec-09 19:14 
AnswerRe: Output error for Avl tree Pin
vtsmokey881-Dec-09 20:04
vtsmokey881-Dec-09 20:04 
GeneralRe: Output error for Avl tree Pin
Nagy Vilmos1-Dec-09 21:40
professionalNagy Vilmos1-Dec-09 21:40 
QuestionBakhshali Approximation for finding the square root of a number..? Pin
silentbob03211-Dec-09 14:27
silentbob03211-Dec-09 14:27 
AnswerRe: Bakhshali Approximation for finding the square root of a number..? Pin
Nagy Vilmos1-Dec-09 21:47
professionalNagy Vilmos1-Dec-09 21:47 
AnswerRe: Bakhshali Approximation for finding the square root of a number..? Pin
Richard MacCutchan1-Dec-09 21:48
mveRichard MacCutchan1-Dec-09 21:48 
QuestionHow to make Swing GUI stable in GridBagLayout Pin
don Moen30-Nov-09 19:20
don Moen30-Nov-09 19:20 
AnswerRe: How to make Swing GUI stable in GridBagLayout [modified] Pin
LunaticFringe2-Dec-09 2:45
LunaticFringe2-Dec-09 2:45 
GeneralRe: How to make Swing GUI stable in GridBagLayout Pin
don Moen2-Dec-09 19:57
don Moen2-Dec-09 19:57 
Questionjava effects Pin
ammu2328-Nov-09 5:23
ammu2328-Nov-09 5:23 
AnswerRe: java effects Pin
Richard MacCutchan28-Nov-09 5:52
mveRichard MacCutchan28-Nov-09 5:52 
AnswerRe: java effects Pin
scottgp28-Nov-09 11:09
professionalscottgp28-Nov-09 11:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.