• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating packages

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am creating a GUI application. I want to separate the back-end code from the GUI code into two separate classes and instantiate the back-end code as an instance in the GUI code. How can I import this code. I am not sure how to create packages in Java and how the directory structure works. I am using Windows (yuck!) to do this. Perhaps, there is a way to do this without creating a package but I am not sure.
Thanks
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are on the right track. Following the MVC paradigm, it makes sense to put your view (GUI) and possibly your controller portions into one package, and your model (i.e. back-end code using your term) pieces in another.
So, put your model related classes in one package, say model, and your view classes in view. The packages should be named something like com.yourCompany.etc, but here we can just refer to them as the model and view packages.
In a directory named model, place your .java source files, each of which have package model; at the top. These classes should expose public interfaces that the view package will consume from.
In a directory named view (a peer directory of model), place your .java source files, each of which have package view; at the top. These classes then would be the GUI/controller pieces that instantiate instances from the model package as necessary.
Hope that helps.
reply
    Bookmark Topic Watch Topic
  • New Topic