• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Beginner Help with Static and Non Static

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 76394
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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'm gonna teach you a lesson! Start by looking at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic