Seperate IO class for NetBeans Form

D

David Segall

I have built a form in NetBeans and NetBeans generates all the screen
widgets as private. I have also written two methods that write and
read the contents of the form to a file. I would like to move those
two methods to a separate class but I don't see how they could access
to the on-screen widgets to get or set the values. Should I give up
the idea of a separate class because the I/O "belongs" with the form
or is there a neat way of communicating between my proposed classes?
 
C

Chris Smith

David Segall said:
I have built a form in NetBeans and NetBeans generates all the screen
widgets as private. I have also written two methods that write and
read the contents of the form to a file. I would like to move those
two methods to a separate class but I don't see how they could access
to the on-screen widgets to get or set the values. Should I give up
the idea of a separate class because the I/O "belongs" with the form
or is there a neat way of communicating between my proposed classes?

There are infinitely many ways of communicating between the proposed
classes. The question of which to choose is rather central one in OO
design. Without knowing more of your application, I'd think that the
simplest thing you could want would be to have a class that encapsulates
the concept (not the GUI widgets or visual representation) of the
information from that form, and put the I/O code there. There are more
complex solutions as well, depending on what exactly you want to
accomplish with your design.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top