Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginner Help with Static and Non Static

 
Tom Carr
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

I am a beginner to java but I have written some basic C# before. But i have never really grasped the OOP concept.
I am starting a project recode for a program i wrote in C# with a better GUI.

Basically in this code I am trying to create a instance of a "LoadIni" class and then get/set the data in it while running its procedures to write to the ini and read from the ini.

Here is my first class EOMWindow:


This is my second class which is called IniControl





The issue i am having is i can't use the line

as it gives the error : non-static varible csvExportDirectoryText cannot be referenced from a static content.
Also i am unable to use the instance "ini" in my button actions (closeButtonActionPreformed) obviously because the IniControl is created within the Run function. How do i place the LoadIni instance so i can access it in the entire EOMWindow class ?

Thanks you very much for reading and any help would be gratefully appreciated .
Tom
 
Tom Carr
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just an update.
I have realised that the error didn't relate to the "ini.ReturnAuditDir" but actually to the csvExportDirectoryText.setText being set from within that void.

But i still have an issue on accessing the "ini" instance in the rest of the class.

Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 47288
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can tell people who come from C#; they go straight for an IDE. And they get code with the IDE’s personality stamped all over it
C# is an OO language, too. How have you managed to write C# without learning object‑orientation?
The ini variable appears to be a local variable in the overridden run() method. When you get to the end of the method, it goes out of scope. You might need an Application class, which has a Wini object as a field. Initialise the field from the Application constructor. That is the sort of thing which is difficult to do from underneath a GUI. You would probably do better to remove the GUI for the time being, and set up the application like a ConsoleApplication. Once you have it running nicely at the command line, then you can replace the GUI on top of it. Obviously you can record your GUI code somewhere to make it easier to reconstruct.

And welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic