Help me structure my classes oop way

I have a combo box for color which takes it's items from a specific table from database. I don't want it to take items directly from db.
I make a Color class which holds id and name, has public methods like getName, setName and save().
I have also made 2 packages to divide GUI and other classes:
GUI
---- window.java
core
--- Color.java
So now I'm confused. Ofcourse there are lots of different ways but I'd like to know the oop way.
Where do I write the code that gets all colors from database?
I'll make a class that basically is a combobox?
I'll make a new class called Colors that extends Color?

That's a bit better. Depends on what they do.
If Color is a class that sub-classes java.awt.Color
(not sure why you would do that, and the description
of it does not sound like it is or would be), then it
might go in a package like com.colorapp.color.
A class called Colors that is a "collection" of Color
classes - if that's what it it, might go in a package
perhaps like com.colorapp.utils.
A class like MyColorCombo - if it's a widget, and why
do you need to subclass one of those? - might go
either in some main class package, or in something
like com.colorapp.gui ...
~Billheh. Color was my bad. Dog would have been better.
You made things clearer.
I thought if ComboBoxDogs extended Dogs, and Dogs extended Dog then they had to make up something like this visually
Dog
--- Dogs
--------ComboBoxDogs
Like package dog, dog.dogs and dog.dogs.comboboxdogs .

Similar Messages

  • Some basic questions: Help defining Real World Classes

    I am trying to write a small applet using proper OO concempts and Java technique and I'm confused on the proper way to do this. I think I know several ways that work and have all the peices I need such as JMail and JDBC drivers, but would appreciate help on understanding how to properly structure my classes and objects.
    The application will simply do the following: I have a database table that receives a new entry when a truck is late for its delivery. When this new record is created, I need to send an email to the driver manager who will then decide (via a jsp page) whether the customer should receive an email about the late delivery. For each truck, there will only be one driver manager and one client to be notified.
    What I'm confused about is what classes and objects to create (and why). My first thought is to create a LateTruck class, a DriverManager class and a Customer class and have the LateTruck class call up the DriverManager to send an email then have the JSP page reinstantiate the LateTruck and instantiate the Customer class to send the email to the client.
    If I do it this way, is there a proper way to send the email? Do I send the email as a method in LateTruck which gets the email address from DriverManager such as
    LateTruck.Order1234.SendEmail(DriverManager.JoeBlow.Email)
    or do I use LateTruck to write the email message which I then pass to DriverManager such as
    DriverManager.JoeBlow.SendEmail(message)
    Should I even break up the applet into three classes and objects? Since each LateTruck only needs one DriverManager and one Client, is the proper way to do this to create only one class called LateTruck which has DriverManager, DriverManagerEmail, ClientName and ClientEmail all as properties of LateTruck?
    Thanks for any help in understanding the basics here.

    Is that the story of Static Write and the Seven Classes and the evil stepmother Wilma Gates who kept asking "Mirror Site, Mirror Site on the web, who's got the buggiest InterDev?

  • Can anyone help me decompile a class file?

    Can anyone pls help me decompile a class file? I've used DJ decompiler and Cavaj decompiler to decompile it but both can't seem to decompile it successfully. How do I attach the class file here? Thanks in advance!

    Oh! Now I get it. So sorry I didnt intend for anybody
    to do something illegal/unethical. I dont know much
    about Java programming since I am very new to this
    language. I didnt know anything about obfuscating
    codes either. The reason why I was trying to
    decompile the said class file is because I wanted to
    check whether the hack program I downloaded ...That is completely contradictory.
    By the way, can you tell me how I can learn Jave programming
    without the aid of a book since I couldnt find one
    yet.Given the eleventy bachillionty kathousand books that exist on java programming, something tells me you haven't looked too hard for one.
    The best non-hard-copy source:
    www.google.com

  • How to trigger New page while using ALV with classes/oops?

    Hi All
    I am trying to print a report which has to show the data in two pages.
    I am using ALV with classes/oops.
    Though I am able to print the report but a new page is not coming. Whole of the data is coming in one single page.
    Please tell me as to how to trigger a NEW PAGE while using ALV with classes/oops.
    Please send some code samples also if available.
    Thanks in advance.
    Jerry

    using sort option you can do it. in case of grid/oo alv class ALV you can view that only in print mode/preview mode.
    in case of list you can view that directly.
    sort-fieldname = 'FIELDNAME'.
    sort-group = '*'  "triggers new page
    sort-up = 'X'.
    append sort to it_sort.

  • Hi, plz can any one help me that is there any way to locate or find the stolen ipon nano???

    hi, plz can any one help me that is there any way to locate or find the stolen ipon nano???

    Other than physically looking for it, no. It does not have WiFi.

  • I accidentally set up my new ipad in itunes under the name of my existing ipad and need to set it up as a new device. Help. I cannot find a way to start fresh.

    I accidentally set up my new ipad in itunes under the name of my existing ipad and need to set it up as a new device. Help. I cannot find a way to start fresh.

    That's probably not a good idea to try to share apps since you will have to switch ID's each time you update apps and sync apps from iTunes.
    And technically - according to Apple's terms - you cannot share apps using different ID's. You can actually lock yourself out of an ID for 90 days if you switch ID's and if you associate the iPad with another ID.
    The bold type is a copy and paste from the site that I referenced below.
    When you turn on iTunes Match or Automatic Downloads, or when you download past purchases on an iOS device or computer, that device or computer becomes associated with your Apple ID. This article describes how to manage these associations.
    http://support.apple.com/kb/ht4627

  • F4 Help in ALV GRID class based

    hi
    you have any idea about how to invoke the F4 help in ALV GRID Class based program.,
    if u have any other related document or program using F4 function in ALV GRId please send to me for reference
    Thanks & Regards
    K.G

    hi for what kind of fields you need to give f4.
    are they std or custom...
    please let me know about the fields..
    try to check my logic which i gave in the below post..
    it will give f4 help to the fields(if thet are standard table fieldS)
    Message was edited by: Vijay Babu Dudla

  • I would like to restore my iphone to ios 4.3.5 from 5.0.1. i've tried and watched videos over youtube  and it doesn't helps. is there any other specific way? the ios 5.0.1 makes my phone crash and drains my battery whenever i tried to switch it back on.

    i would like to restore my iphone to ios 4.3.5 from 5.0.1. i've tried and watched videos over youtube  and it doesn't helps. is there any other specific way? the ios 5.0.1 makes my phone crash and drains my battery whenever i tried to switch it back on. kindly help me.

    There is no legit way to do this at all.

  • Hi I need help on URL Connection Class

    Hi
    I have read the documentation but cant get it . I have to Use the getContent(); method so can any one make a program for me in which all of the methods of this class have been used?
    I Also Need help on Content Handler Class Please give me one example on it but separate from the above one
    Thanx alot

    Hi
    Man Some Times We need help and as of google, Google is My Best Friend. and as of forums search i know that but some time we have less time and much to work. The Time Doesnt wait us. we have to save our time. thanx for ur help and ur comments i like it.

  • This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    If you're just reading them from email attachments, you can just open it to "view" the document.
    However, if you wish to do editing and work, you'll need an application. I use Documents to Go, but there are other versions that people are happy with - do a search in the App store for "office suite" or "word processing".
    The next challenge is getting docs back and forth. Doc2Go and others have their own ways to physically sync docs when connected to a computer; you can also email changed/revised/new documents from the iPad to yourself. However, I use a "cloud service" called DropBox that stores docs in the cloud (so I can get to them anywhere) - I paid for the Premium version of Docs2Go to allow that kind of syncing.

  • Help...is there a way to send an entire text mesage thread to my email?  My phone is sending duplicate texts and everything I am reading says to delete message threads.  I have an IPhone 4. thanks

    Help...is there a way to send an entire text mesage thread to my email?  My phone is sending duplicate texts and everything I am reading says to delete message threads.  I have an IPhone 4. thanks

    You can try an app like PhoneView (Mac) or TouchCopy (Mac or PC). Both will allow you to archive text messages to your computer.

  • Help : documentation The Robot Class

    hi,
    is there somone who know about the robot class either the documentation of the API, some internet web site ..
    thanks

    What are you wanting to know?? I helped create the Robot class. This class was purposely kept extremely minimal, and the javadoc for it is pretty good. If you want a more complete tool, you can try Jemmy (http://jemmy.netbeans.org/), though I should warn you that the documentation there is skimpy. Jemmy builds on top of Robot and provides lots of flexibility.
    - David

  • Structure pour classe évolutive (LV OOP)

    Bonjour,
    Quelle est la structure la plus adaptée pour gérer des classes qui sont susceptibles d'évoluer ? L'évolution consistera le plus souvent en un ajout de "variables membres". Je souhaiterais faire évoluer les classes tout en pouvant relire les objects sauvegardés dans la version précédente. Pour des raisons pratiques (grand nombre d'objets sauvegardés, sur des serveurs pas toujours accessibles),  j'aimerais ne pas avoir à "convertir" mes anciens fichiers dans le nouveau format.
    Comment construire ma classe initiale pour pouvoir dans le futur passer en version 2 tout en pouvant accéder à mon carnet d'adresse vieux de la version 1 ?
    Exemple :
    Classe version 1 : Demoiselle admet comme variable nom et numéro de téléphone
    Puis dans la version 2, j'ajoute à ces 2 variables un booléen "est-elle mariée ?"
    Espérant que la question est compréhensible.
    Merci !
    Résolu !
    Accéder à la solution.

     Bonjour petitOhu,
    Merci d'avoir posté sur le forum National Instruments.
    Je ne suis pas certain de bien comprendre ta question car il me semble que tu peux ajouter un élément dans la définition de ta classe (dans le *.ctl) sans pour autant "casser" les accesseurs ou propriétés/méthodes déjà existants.
    Finalement, il est aussi possible d'utiliser un serveur de contrôle de code source afin d'avoir un suivi de l'historique de ton développement. De plus, cela te permets de revenir à une version précédente facilement, de gérer le fait de développer à plusieurs... Voici un tutorial sur ce point.
    N’hésites pas à préciser ta question si je n’ai pas bien compris ce que tu cherche à faire.
    Benjamin R.
    R&D Software Development Manager
    http://www.fluigent.com/

  • Structured Properties class

    Hi!
    I'm wondering if there is a class similar to the Properties class that outputs it content in a structured way. That is, if you use the Properties class to read properties from a properties file and then you modify its content and write it out to a file, there will not be the same structure in the output file as in the input file.
    What I'm looking for is a class that can be used to parse properties files and where it is possible to change properties, but the output has the property names in the same place (in the file) as the input, but the property values might have changed.
    Would really appreciate some help!
    Best regards
    Lars

    there is no standard class for it. i think the best (and also an easy solution) is to do the input/output via a XML wrapper (written by yourself), with the available XML tools this is simple.
    if you are going to use JDK1.4 have a look at the Preferences API: i think it is great!

  • Help Determining Which Methods/Classes Are Being Used

    Hello,
    I'm having issues with my company's Java application and because I've luckily narrowed the classes down to a meager 30+ I need some help pinpointing my problem.
    I realize there are a lot of Java monitoring applets/applications and some are deployment-specific but I need something very detailed-- I haven't found the features I need.
    Specs:
    Jrun4, Java 1.4, Windows Server 2003
    I would like to have a monitor that tells me exactly (real-time) what classes, methods, variables, etc. are being called in real-time. Looking at the JRun launcher console for one process gives me this:
    Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
    01/16 14:05:33 error Software caused connection abort: socket write error
    java.net.SocketException: Software caused connection abort: socket write error
            at java.net.SocketOutputStream.socketWrite0(Native Method)
            at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
            at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
            at jrun.servlet.io.MetricsOutputStream.write(MetricsOutputStream.java:75)
            at java.io.BufferedOutputStream.write(BufferedOutputStream.java:106)
            at jrun.servlet.http.WebOutputStream.write(WebOutputStream.java:64)
            at jrun.servlet.file.FileServlet.pipeData(FileServlet.java:419)
            at jrun.servlet.file.FileServlet.service(FileServlet.java:254)
            at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
            at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)This is cute, but not really helpful. I would like to determine what was passed to the process, from where and what went wrong.
    For example,
    Instead of this:
    Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
    01/16 14:05:33 error Software caused connection abort: socket write errorI would get something like this:
    Generating report:quadbase.reportdesigner.ReportAPI.QbReport with export type:PDF
            Page variables: test.jsp ($var1= "I'm"; $var2= "Going"; $var3="To"; $var4="Break"; $var5 = null)
            Calling: test2.jsp
            With: jrun.bin.db.foo.Bar();
    01/16 14:05:33 error Software caused connection abort: socket write error
            Problem: $var5 = null;Sorry if I'm rambling, I just want to know what is where and who it's calling when it breaks. Then I could deduce which class, what variable, what page, etc. My application is very complicated and seemingly mundane changes can throw it all off.
    Any ideas?

    We'll look into usage tracking. We're on the standard edition, so I'm not sure if it's available. Also, some of these reports may be quarterly -- so there may be a long wait to see if the view is used and I need to know fairly soon. (If it's not used, it saves us some work in a project transition going on.)
    I certainly don't understand the underlying structure of the product, but it seems like there should be some way to determine if a view is used by a report. I apologize if I'm not using the correct terminology. Thanks for your help -- we'll keep looking into it.

Maybe you are looking for

  • How to change linux text area background color?

    Hi, I like to know the method. just like in windows platform.

  • Trouble with Simple XNET CAN Example...

    I am trying to get a simple XNET CAN write frame going. Here is the VI I created... I keep getting this: I looks like I have a frame set up, so what else could be the issue?

  • Canon Powershot SD1100, importing videos freezes iPhoto 08?

    To Group: I recently got a new puppy and have been taking quite a few short video clips with my Canon SD1100, however when I try to import them into iPhoto 08 the application just freezes and eventually closes. Upon reloading iPhoto it says that X nu

  • Cost element table

    hi, is theere any standard se16n table to view all the cost elemnts (primary and sec) or any other way to find it. plese let me know. thanks.

  • MIGO Actual Cost

    Hi, Friends, In PO i maintained Rs 100 and given 20/- discount and my price also appearing as 80 as net value is showing in PO . But when i do MIGO it is posting as 100/- to Inventory why it is happening ? My doubt is there is one setting in sub tota