Announcement

Collapse
No announcement yet.

Abstract Java Programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Abstract Java Programming

    First off, i know there is a java coding website with all sorts of nerds and things, but this is my home of all my questions. I don't like to stray very much.. so here I go.

    I'm fairly good (in terms of an amature) at java programming. I look threw all the libraries to see what i can use and spit out a few programs every now and then. Lately I've been working on a program for my church for the sound box that has both ASL and Hearing. so far this this program is mostly complete.

    I have 2 packages, and 1 class that made to run everything.

    the 2 packages are very similar to each other and actually extend Frame (i know i should use java.swing but again, the whole straying thing) both packages also implement WindowListener, ActionListener, MouseListener.

    now for the question. because I didn't make those packages abstract I have to implement all the different processes that WindowListener and MouseListener have to offer even though i'm only using 1 process for each. How do i declare my packages abstract and still be able to instantiate them?

    Code:
          if (ActOnWhat.equals("Hearing"))
          {
            SHFrame songFrame = new SHFrame("Choose Your Song");
            soundFrame.dispose();
          }
          else if (ActOnWhat.equals("ASL"))
          {
            AHFrame aslFrame = new AHFrame("ASL");
            soundFrame.dispose();
          }
    that code is essentially all i have my main program do. If i make SHFrame and/or AHFrame abstract, the main program won't compile..it says: class is abstract cannot be instantiated. anyideas?? As of now the program works all i have to do is finish downloading the almost 30 dvd's and split them and then make the program properly look them up. If you want the rest of the code you can get it emailed to you. I'm not going to post it all. thank you.
    WTB:
    88-01 prelude 2.0si (3g) si (4g,5g)
    OR
    90-93 Accord.

    Has to be 5spd, has to be CHEAP. SUPER CHEAP. Will be in Indiana in February permanently and want a project car when I get settled in.


    #2
    The compiler is correct. You cannot instantiate any class that is declared abstract.

    What you can do is create another class that extends your abstract class and then implement any of the methods if you need to. You will be able to create an instance of this new class.

    Members Ride Thread

    Comment


      #3
      well I have another question now. same program, just trying to get keylistener to work.
      I have a frame with 16 buttons (a number pad, next, clear, play [1,2,3], ) it has 3 panels that display song numbers. you use the number pad to enter in song 1, hit next, then enter in song 2, hit next, then enter song 3. that's it. I'd like to have the key board as a back up option if the mouse fails. I've tried adding the keylistener to every part in that frame, but all to no avail. The listener is never being thrown. If i add a textfield and type in it and add a listener to it it works... but that's it. so far. so any ideas??? someone need some code to look at? thank you palinix for your help, i'll use it sometime i'm sure.
      WTB:
      88-01 prelude 2.0si (3g) si (4g,5g)
      OR
      90-93 Accord.

      Has to be 5spd, has to be CHEAP. SUPER CHEAP. Will be in Indiana in February permanently and want a project car when I get settled in.

      Comment

      Working...
      X