• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to transfer data when the 1st class calls the 2nd and 3rd, and the 2nd needs the 3rd.

 
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay so I have a class called Main which calls the draw class into a panel(works). Also in the main class I have a file opener to which the file is needed to read in the format class(works). This format class has info the draw class needs. How can I do this? I tried making a method to return the format class info, but I have to do Main main = new Main(); in the draw class which causes an infinite loop. So essentially I only need the format class data, how can I pas it along? I tried static also(not sure how static works fully either).

Im thinking this is important in a lot of things.... if I don't make 100% sense I will post some code.


The only thing I can think of is having a central class for storing everything in case some classes need others especially the data coming into the "main" class.... Maybe I will do that, so that way I only need the data and don't care about the rest of the class and if I do care I will have it called. I could also have another class for this one thing and maybe this might be a one time occurrence.
 
author & internet detective
Posts: 41250
849
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I might not be understanding the problem correctly, buy why can't you have a data transfer object that you pass around?

Main
HelperDto d = new HelperDto();
Panel p = new Panel(d);
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention that I believe I figured out the issue.

Class 1 Main is a Jframe and calls Draw which extends JPanel...

Draw needed the information in the format class to work.

Main has the menus which the "Open" menu is for selecting files[]. These files are read and then set into the format class. Once that's done I have to call it in the Draw Class. Now I realized I could just make a Constructor of Draw to read in the Format classes information and/or the file. I was really tired when I was doing this, and figured it out later in the day :P.
 
grapes are vegan food pellets. Eat this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic