Link to home
Start Free TrialLog in
Avatar of Drop_of_Rain
Drop_of_Rain

asked on

Look over this class

Hello everyone thanks for all your support. I have another question. I modified
this class to be able to have a user set a timer and then store the total number
of Milliseconds to a variable. I then need to pass this to a TimerClass or should
 i just have it as a inner class in this one?

Can you go over it and see if i got it right.


I added these If statement to stop the down button from working if the int was 0
Will these work?


if (hr = 0)     // stoping the down button from working when the number is 0
{
    this.guiPanel.downButton.enablied(false)
}


if (hr = 0)     // stoping the down button from working when the number is 0
{
    this.guiPanel.downButton.enablied(false)
}

I also added these are these correct?

int hrms = hr * 60 * 60 * 1000;  // convert hr to Milliseconds
int minms min * 60 * 1000;       // convert min to Milliseconds
userTimerAlarm = hrms + minms;   // store total Milliseconds


package my.test;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JLabel;
import my.test.GuiPanel.Mode;


class AdvanceModeAction extends AbstractAction
{
    private final GuiPanel guiPanel;

    public AdvanceModeAction(GuiPanel guiPanel, String name)
    {
        super(name);
        this.guiPanel = guiPanel;
    }



    public void actionPerformed(ActionEvent e)
    {
        String cmd = e.getActionCommand();
       
        if (this.guiPanel.currentMode == Mode.Timer)
        {
            this.guiPanel.timeDisplay.setText("00:00:00"); //Reset time to 0
           
            if (cmd.equals(this.guiPanel.hourButton))
            {
               selected = HR;
            }
            else                if (cmd.equals(this.guiPanel.minutesButton))
                {
                   selected = MIN;
                }
                else                    if (cmd.equals(this.guiPanel.upButton))
                    {
                        if (selected == HR)
                        {
                            String time = this.guiPanel.timeDisplay.getText();
                            String[] splitTime = time.split(":");

                            int hr = Integer.parseInt(splitTime[0].trim());
                            time = Integer.toString(hr + 1)  + ":" + splitTime[1] + ":" + splitTime[2];

                            guiPanel.timeDisplay.setText(time); //modified time
                        }
                        else                            if (selected == MIN)
                            {
                                String time = this.guiPanel.timeDisplay.getText();
                                String[] splitTime = time.split(":");

                                int min = Integer.parseInt(splitTime[1].trim());
                                time = splitTime[0] + ":" + Integer.toString(min + 1)  + ":" + splitTime[2];

                                guiPanel.timeDisplay.setText(time); //modified time
                            }
                    }
                    else    if (cmd.equals(this.guiPanel.downButton))
                        {
                            if (selected == HR)
                            {
                                String time = guiPanel.timeDisplay.getText();
                                String[] splitTime = time.split(":");
                                 
                          if (hr = 0)     // stoping the down button from working when the number is 0
                                  {
                                      this.guiPanel.downButton.enablied(false)
                                  }
                               
                         int hr = Integer.parseInt(splitTime[0].trim());
                                time = Integer.toString(hr - 1)  + ":" + splitTime[1] + ":" + splitTime[2];

                                guiPanel.timeDisplay.setText(time); //modified time
                            }
                            else if (selected == MIN)
                                {
                                    String time = guiPanel.timeDisplay.getText();
                                    String[] splitTime = time.split(":");

                                    int min = Integer.parseInt(splitTime[1].trim());
                                     
                               if (min = 0)   // stoping the down button from working when the number is 0
                                         {
                                              this.guiPanel.downButton.enablied(false)
                                         }

                             time = splitTime[0] + ":" + Integer.toString(min - 1)  + ":" + splitTime[2];

                                    guiPanel.timeDisplay.setText(time); //modified time
                                }
                        }
                        else     if (cmd.equals(this.guiPanel.okButton.getText()))
                            {
                                //time should be stored in timerDisplay
                               
                                this.guiPanel.alarmStarted = true;
                               
                        Int hrms = hr * 60 * 60 * 1000;  // convert hr to Milliseconds
                        Int minms min * 60 * 1000;       // convert min to Milliseconds
                        userTimerAlarm = hrms + minms;   // store total Milliseconds
                        
                        this.guiPanel.alarmTime = this.guiPanel.timeDisplay.getText();
                                selected = HR;
                                this.guiPanel.currentMode = Mode.Clock;
                                this.guiPanel.modeDisplay.setText(this.guiPanel.currentMode.toString());
                                this.guiPanel.dispProv.setDispListener(this.guiPanel.timeDisplay);
                            }
           }
    }

 }
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use the MyTimer class in your other question if the Mode is correct. I would write the if statements as a switch/case statement as in my earlier examples
Avatar of Drop_of_Rain
Drop_of_Rain

ASKER

Does it look right above?

The problem i had with doing that in another class seems that it wanted an int to use as the case. I must be missing someithing here. Here is the Case you gave me.

private class AdvanceModeActionCase extends javax.swing.AbstractAction
{
      public AdvanceModeActionCase(String name)
      {
            super(name);
      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
            advanceMode();
            enableAllButtons();

            switch (currentMode)
            {
                  case Alarm:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);

                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
                        break;

                  case Audio:
                        hourButton.setEnabled(false);
                        minutesButton.setEnabled(false);
                        break;

                  case Clock:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Date:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Timer:
                        recordButton.setEnabled(false);
                      stopButton.setText("Reset");
                           fastButton.setEnabled(true);  // changes like these
                           fastButton.setText("Reset");  // changes like these
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;
                       
            }


      }
}
>>that it wanted an int to use as the case

You should be using the enum that i gave you (Mode). If it's case Audio, start playing, with or without a Timer
I just went to that question and copied what you gave me here it is.
https://www.experts-exchange.com/questions/22696219/Changing-action-command-by-changing-text-in-the-button.html
 So how would this be added to this class?

When i added this to this class it says it can not be local, can you tell me what is happening here?
  enum Mode {
       Clock, Date, Alarm, Timer, Audio, Custom,
   };

private  class AdvanceModeAction extends javax.swing.AbstractAction
{
      public AdvanceModeAction(String name)
      {
            super(name);
            enum Mode {
                    Clock, Date, Alarm, Timer, Audio, Custom,
             };

      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
            advanceMode();
            enableAllButtons();

            switch (currentMode)
            {
                  case Alarm:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);

                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
                        break;

                  case Audio:
                        hourButton.setEnabled(false);
                        minutesButton.setEnabled(false);
                        break;

                  case Clock:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Date:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Timer:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        dispProv.setDispListener(timeDisplay);
                        break;
            }


      }
}
           enum Mode {
                    Clock, Date, Alarm, Timer, Audio, Custom,
             };
So would i just chane currentMode to Mode?


private  class AdvanceModeAction extends javax.swing.AbstractAction
{
      public AdvanceModeAction(String name)
      {
            super(name);
           
      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
            advanceMode();
            enableAllButtons();

            switch (currentMode)  // switch currentMode to Mode
            {
                  case Alarm:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);

                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
                        break;

                  case Audio:
                        hourButton.setEnabled(false);
                        minutesButton.setEnabled(false);
                        break;

                  case Clock:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Date:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Timer:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        dispProv.setDispListener(timeDisplay);
                        break;
            }


      }
}
So is this right now, sorry for not trying more earlier.


   public  enum Mode {
        Clock, Date, Alarm, Timer, Audio, Custom,
    };

private  class AdvanceModeAction extends javax.swing.AbstractAction
{
      Mode mode;
      public AdvanceModeAction(Mode mode)
      {      this mode = mode;
                       
      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
            advanceMode();
            enableAllButtons();

            switch (mode)  // switch currentMode to Mode
            {
                  case Alarm:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);

                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
                        break;

                  case Audio:
                        hourButton.setEnabled(false);
                        minutesButton.setEnabled(false);
                        break;

                  case Clock:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Date:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Timer:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        dispProv.setDispListener(timeDisplay);
                        break;
            }


      }
}

ASKER CERTIFIED SOLUTION
Avatar of CPlusJavaCSharp
CPlusJavaCSharp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To ensure accessibility it would probably be better to compile

 public  enum Mode {
        Clock, Date, Alarm, Timer, Audio, Custom,
    }

in its own source files
in its own source files=in its own source file
Ok now you have lost me, what do you mean by source file. I though a source file was a file of java code not compiled. What do you mean. Please explain this to me. I looked it up and that was all i found. Should i make them all caps?

CEHJ:To ensure accessibility it would probably be better to compile

 public  enum Mode {
        Clock, Date, Alarm, Timer, Audio, Custom,
    }

in its own source filesAccept Multiple Solutions Accept as Solution
   
 CEHJ:in its own source files=in its own source file
>>I though a source file was a file of java code not compiled.

It is
IS THIS WHAT YOU MEAN?

public class ModesClass {
   
    /** Creates a new instance of ModesClass */
    public ModesClass() {
    }
     enum Mode {
        CLOCK, ALARM, TIMER, AUDIO, DATE, CUSTOM,
    };

}
Ah i see the confusion. An enum is really a class. You don't need to wrap it in another. Save the last source i posted as Mode.java

btw CPlusJavaCSharp is right about the case of the symbols. Making the enums upper case signals to readers of the code that constants are being used. So

public enum Mode {
        CLOCK, ALARM, TIMER, AUDIO, DATE, CUSTOM,
}
Or something like this?

public class ModesClass {
   
     public ModesClass() {
    }
     public getMode(){
                  enum Mode {
                          CLOCK, ALARM, TIMER, AUDIO, DATE, CUSTOM,
                    };
       }

}
No. See my last post
I had this in my earier post which is the same except the CAPS. So were will this code go, in the class?
Now that we have this clear, but we have gotten off what the original question was, could you go back up and look at it. You never answered it

 public  enum Mode {
        Clock, Date, Alarm, Timer, Audio, Custom,
    };
>>I had this in my earier post which is the same except the CAPS.

No - it isn't the same. There is a terminating semi-colon.

>>So were will this code go, in the class?

I've already said - in its own source file
How is this source file structured, I can't find anything about how to.
See your earlier questioin where I explained about simplifying your listener.
You don't need *any* if/case statements. Whenevr you start doing things like that it generally means theres a problem in your code.
In this case you need seperate listener for buttons with different action, which is in fact how they are meant to be used. One listener for all button defaets the purpose of being able to specify listeners :)

eg.

public AlarmListener inmplements ActionListener
{
    public void ationPerformed(ActionEvent e)
    {
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);

                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
   }
}

nice and simple, and clear :)
Objects:  The case statement above are based upon the text in a label being changed because of a button being pressed and each time the button is pressed it  cycles through the enum. It is the change in the label here is is being looked at. So then it would be a PropertyChangeListene for the label and the text change in it?  I would still need to use If statements to look at the property change, so what would be the real difference?

Go to the top of the page and look at my oringinal question, everyone has gotten off that. I would like to know if I am right with the changes i made.
CEHJ:
I don't see anything in EE database or in Google about enum being or needing to be in a seperate file.
> The case statement above are based upon the text in a label being changed because of a button

Thats not what the code above is doing :)

> I would still need to use If statements to look at the property change

Nop, you wouldn''t need an if (or an enum). Thats just over complicating things.
Just break the Action up into seperate Action's, thats how they are meant to be used.
oobjectsL do me a favor and go to the oringinal question, because the code we are talking about is not what I started with in this question. PLEASE RE-READ MY FIRST POST
yes, i just was :) people far too often sidetrack q';s abnd confuse other experts. one of the many problems my students have with this site.
same principle applies to the code in your question, they are differentactions and as such should be implemented in different Action classes.
In this case you would implement it by either changing the listener of the button when the mode changed, or
make the mode your action, then in your buttonm listener just call the action

    public void actionPerformed(ActionEvent e)
    {
        this.guiPanel.currentMode.actionPerformed(e);

nide and simple :)
this.guiPanel.currentMode.actionPerformed(e);  But won't this still be just one listener I don't see the difference. If the mode is changing isn't that a propertychange? The property of the text of the label has changed. The buttons will always work the way they do, like the up, down, hour, minutes, but they will be different classes for each mode because different stuff has to happen with each on. One is for setting the amount of time for a timer, another will be for setting the time in an alarm, another will be for adjusting the date. Because for each mode i change some of the button's text and then use the text property to take action from.

I'm not getting what you are trying to get me to see, sorry.
> But won't this still be just one listener I don't see the difference.

when the mode changes, the listener stored with currentMode will be changed.

> One is for setting the amount of time for a timer, another will be for setting the time in an alarm, another will be for adjusting the date.

So they should be different actions. Theres no relationship between the actions so theres no reason to group them all in one action.
> If the mode is changing isn't that a propertychange?

It may be a property change (am not sure how iuts implemented at that end), but it should *trigger an action change*. ie. when the mode changes, the *behavior* changes. Thus you change the acvtion that gets executed.

There is a JLabel and the text is changed by it advancing through the enum  which has the Modes as CONSTANTS in it. The class in the question is just for being able to adjust the minutes and hours, store the amount for the hours and minutes and then add them together to total the number of milliseconds for the timer. and then change the mode back to CLOCK when the OK button is pressed, display the time again and call another class to handle the timer and audio. I don't see why it is wrong to use it this way. Explain to me why it shoul be done another way. It seens pretty solid to be working with the CONSTANTS.
Why?  Because you end up with a convoluted if/switch instead of a single method call.
Mode isn't just a constant, it defines a change in behaviour. Thats *not* what enum's are for.
If each mode needs any attrributes (eg. a String) these can also be added as properties of the Mode action

eg.

public ModeXyz extends AbstractAction
{
   public ModeXyzAction(String name)
   {
        super(name);
   }

    public void actionPerformed(ActionEvent event)
    {
        // perform required action for mode xyz
    }
}
unum are just CONSTANTS right that is why they are in all CAPS. So it seens to me there id the mode type and the hour button and the minute button and the up and down buttons could be handles in the hour button action. Then there is the MInutes button action and the up and down buttons could be handled in the Minutes button action. Ok I can see that would be much cleaner code. So that way we would still be looking at the mode but with the button action as well.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well with the alarm when the mode is changed to alarm certain button are enabled(false) because they have nothing to do with the mode. The hour, minutes, up, down, Ok buttons are enabled. The timeDisplay which is a JLabel is were the time is displayed. The user presses the hour button which allows then to adjust the numbers in the hour display up or down, I still have to handle the am pm thing. The minute button does the same thing. Now this is true for both the alarm and timer mode. The only difference is I reset the display for the timer to 00:00:00. These 2 mode are the same with the buttons.
> when the mode is changed to alarm certain button are enabled(false) because they have nothing to do with the mode.

thats an action then

> The only difference is I reset the display for the timer to 00:00:00.

The button action could call the mode action (as I showed earlier) allowing the mode to do any specific things like resetting timer display.

how do u change mode?
With the mode button
so what the action for that mode button should do is change the mode instance that defines mode behaviour.

But take it one step at a time.
First take the action for a particular button and create a specific action for it. At this stage ignore mode, once the actions working we'll see what differences are needed depending on mode.
So each button will get a new listener, ae, be, ce, de, etc or would it be better to name it so it is readable like modeaction, upaction, downaction, etc that way the code will be readable correct?
If I use the button to do the same thing over then I should use the same label to make all the changes in as well correct. That way the code stays consistent. The reason i say this is because I haven't done the date mode yet, but I could still use the same label because all it is is just different formatting. I was thinking at the beginning to use a different fram for it, but as i am learning i am realizing that more can be done with what is already there. Thanks for being patient with me, i appreciate it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I was thinking was to get the basic concepts working in a prototype version with the code that i have. I could then change the code to be cleaner and better as i go. What are you thoughts about this. I would like to get the basic pieces together and working and then make the changes so we go. I want to make this application public and give you guys credit for helping with it. I think that people can use this in their offices and at home. I would like to add to this program so that can call your cell phone or other number and play the messages you have when it is time to.
< u can label your buttons differently if it makes your gui clearer, otherwise yes keep it consistent

I ment the JLabel, it is used for the clock, timer, alarm and can be used for the date as well.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK you know more then me. It sounds like I might need to do some restructuring.

What I am thinking now as that i have a Controler class that monitors the modes Then their is a mode class that handles that mode and calls on other classes. That way evrything about that mode is under one roof. I can have one class that handles the button properties and if enabled or not,  then a class that handles all audio calling on subclasses etc. I think this is the direction I need to go.
let me know if u have any questions along the way :)
So with the ModeController I'm thinking to use a propertychangelistener because all it will need to do is know is when the mode has changed. One listener for one JLabel. For the ButtonControl Class I'm thinking I can use the enum because it is following the same action as the JLabel listener but not using it.
 I will need to create a class for each mode and have then do what ever needs to be done. I will add new action listeners for each button with the name I shared, except for the buttons that change which are 2 i think. I will use actionCommand with them because I can use the text of the button to control the flow of what happens. So what do you think of this plan?

         You said that the audio player I found is the wrong type, can i use audioclip from the applet?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I did a rundown on all the buttons, and they have alot of differnt uses. It seemed easy to me to only have to use one listener watching the JLabel because that is the only thing that changes with the mode button. Nothing else happen until the OK button is pressed which will have it own listener, i like that idea.. It seems logical to me to do it that way. Simple and easy. As for using the enum all it is basicly is a array of CONSTANTS that don't change but can be added to and expanded very easy. I am thinking simple from my view point. So that is were my thinking is coming from.
Thanks for the audio examples.
> It seemed easy to me to only have to use one listener watching the JLabel because that is the only
> thing that changes with the mode button.

sounds like you've got it the wrong way around :)  You shouldn't be listening to label changes.
Your mode button listener should handle updating the label and the current mode.
DOn't think you'll need any enums from what you've told me.


Well I know you are right but I'm going to need some help getting this started. Other experts from this site have made these recomadation and contributed code as well. I am not one to know if what they suggest is right. But I will say i want to learn to think in the right way in my programing. I know from experince that a way can appear to be right, but it doesn't mean that it is the right way. A right way looks from many perspectives and levels at the same time which gives it more depth.
 
        So I am very willing to learn from you but I will need you help to get there.

        OK I just got it, the mode button does one thing as well, so how will itdo all this, show me some code enough to give me enough direction to put it together.
how many modes are there?
CLOCK, ALARM, TIMER, AUDIO, DATE, REMINDERS, CUSTOM,
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I like the layout the way it is, I just tried the radio button but if I expand it in the future, i will have to chage the whole gui, if i keek it this way i can add as much as i want without having to change as much. I see that for the Reminders and Custom modes I will bring up another window and work from it, to much for the gui to handle.

ModeLabelUpdater updater = new ModeLabelUpdater(modeLabel);
clockRb.addActionListener(updater);   What is the Rb
alarmRb.addActionListener(updater);
what are you currently using?
But I'm not attached to it as well. I am just not very good at it so I amshying away from it. Even though i can use Netbeans which makes it really easy. Can we have text travel accross a label like a ticker tape using java, I know they have it in JavaScript. I'm just asking because i though it might be a good way of getting info to a user, what are yoyr thought. I ask this now because of the possibility of changing the GUI. Let me know
yes you can have a ticker.
what does the user currently use to change the mode?
Here is the code for the GuI so you can see what it is i am working on. it has a main

import javax.swing.*;
import java.util.ArrayList;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import java.awt.event.ActionEvent;
import java.lang.*;
import javax.swing.JLabel;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;



public class GuiPanel extends javax.swing.JFrame
{
   enum Mode {
       CLOCK, ALARM, TIMER, AUDIO, DATE, REMINDERS, CUSTOM,
   };

   private java.util.List<Mode> modes;
   private int modeIndex;
   private Mode currentMode;
   boolean alarmStarted = false;
   public String alarmTime;
   //   private/** Creates new form GuiPanel */
   public GuiPanel()
   {
      initComponents();
      initModes();
   }


   private void initModes()
   {
      modes = new java.util.ArrayList<Mode>();
      for (Mode m : Mode.values())
      {
         modes.add(m);
      }
      modeButton.setAction(new AdvanceModeAction("Mode"));
      advanceMode(); // Advance mode to Clock
   }

   private class AdvanceModeAction extends javax.swing.AbstractAction
   {
      public AdvanceModeAction(String name)
      {
         super(name);
      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
         advanceMode();
         

         enableAllButtons();

         if (currentMode == Mode.ALARM)
         {
            recordButton.setEnabled(false);
            playButton.setEnabled(false);
            stopButton.setEnabled(false);
            fastButton.setEnabled(false);

            alarmTempDisplay = new JLabel(timeDisplay.getText());
            alarmStarted = false;
            dispProv.setDispListener(alarmTempDisplay);
         }
         else if (currentMode == Mode.AUDIO)
         {
            hourButton.setEnabled(false);
            minutesButton.setEnabled(false);

         }
         else if (currentMode == Mode.CLOCK)
         {
            recordButton.setEnabled(false);
            playButton.setEnabled(false);
            stopButton.setEnabled(false);
         }
         else if (currentMode == Mode.DATE)
         {
            recordButton.setEnabled(false);
            playButton.setEnabled(false);
            stopButton.setEnabled(false);
         }
         else if (currentMode == Mode.TIMER)
         {
            recordButton.setEnabled(false);
            playButton.setEnabled(false);
            stopButton.setEnabled(false);
            dispProv.setDispListener(timeDisplay);
         }


      }
   }

   private class AlarmButtonSelectAction extends javax.swing.AbstractAction
   {
      public final int HR = 0;
      public final int MIN = 1;

      int selected = -1;

      public void actionPerformed(ActionEvent e)
      {
         String cmd = e.getActionCommand();
         if (currentMode == Mode.ALARM)
         {
            if (cmd.equals(hourButton.getText()))
            {
               selected = HR;
            }
            else if (cmd.equals(minutesButton.getText()))
            {
               selected = MIN;
            }
            else if (cmd.equals(upButton.getText()))
            {
               if (selected == HR)
               {
                  String time = timeDisplay.getText();
                  String[] splitTime = time.split(":");

                  int hr = Integer.parseInt(splitTime[0].trim());
                  time = Integer.toString(hr + 1) + ":" + splitTime[1] + ":" + splitTime[2];

                  timeDisplay.setText(time); //modified time
               }
               else if (selected == MIN)
               {
                  String time = timeDisplay.getText();
                  String[] splitTime = time.split(":");

                  int min = Integer.parseInt(splitTime[1].trim());
                  time = splitTime[0] + ":" + Integer.toString(min + 1) + ":" + splitTime[2];

                  timeDisplay.setText(time); //modified time
               }
            }
            else if (cmd.equals(downButton.getText()))
            {
               if (selected == HR)
               {
                  String time = timeDisplay.getText();
                  String[] splitTime = time.split(":");

                  int hr = Integer.parseInt(splitTime[0].trim());
                  time = Integer.toString(hr - 1) + ":" + splitTime[1] + ":" + splitTime[2];

                  timeDisplay.setText(time); //modified time
               }
               else if (selected == MIN)
               {
                  String time = timeDisplay.getText();
                  String[] splitTime = time.split(":");

                  int min = Integer.parseInt(splitTime[1].trim());
                  time = splitTime[0] + ":" + Integer.toString(min - 1) + ":" + splitTime[2];

                  timeDisplay.setText(time); //modified time
               }
            }
            else if (cmd.equals(okButton.getText()))
            {
               //time should be stored in alarmDisplay
               
               alarmStarted = true;
               alarmTime = timeDisplay.getText();
               selected = HR;
               currentMode = Mode.CLOCK;
               modeDisplay.setText (currentMode.toString());
               dispProv.setDispListener(timeDisplay);                
               selected = -1;
            }
         }
      }

   }


   private void enableAllButtons()
   {
      downButton.setEnabled(true);
      fastButton.setEnabled(true);
      hourButton.setEnabled(true);
      minutesButton.setEnabled(true);
      modeButton.setEnabled(true);
      okButton.setEnabled(true);
      playButton.setEnabled(true);
      recordButton.setEnabled(true);
      stopButton.setEnabled(true);
      upButton.setEnabled(true);
   }

   private void advanceMode()
   {
      currentMode = modes.get(modeIndex++ % modes.size());
      modeDisplay.setText(currentMode.toString());
   }
   void getModeDisplay()
   {
      currentMode = modes.get(modeIndex++ % modes.size());
   }

   /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
   // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
   private void initComponents()
   {
      jPanel1 = new javax.swing.JPanel();
      jLabel1 = new javax.swing.JLabel();
      timeDisplay = new javax.swing.JLabel();
      jPanel2 = new javax.swing.JPanel();
      modeDisplay = new javax.swing.JTextField();
      jPanel3 = new javax.swing.JPanel();
      modeButton = new javax.swing.JButton();
      okButton = new javax.swing.JButton();
      hourButton = new javax.swing.JButton();
      minutesButton = new javax.swing.JButton();
      recordButton = new javax.swing.JButton();
      playButton = new javax.swing.JButton();
      fastButton = new javax.swing.JButton();
      stopButton = new javax.swing.JButton();
      upButton = new javax.swing.JButton();
      downButton = new javax.swing.JButton();

      AlarmButtonSelectAction alarmButtonSelectAction = new AlarmButtonSelectAction();

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      setResizable(false);
      jPanel1.setBackground(new java.awt.Color(255, 255, 255));
      jLabel1.setFont(new java.awt.Font("Tahoma", 2, 18));
      jLabel1.setForeground(new java.awt.Color(51, 51, 255));
      jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      jLabel1.setText("Audio Reminder Panel");

      timeDisplay.setFont(new java.awt.Font("Tahoma", 0, 36));
      timeDisplay.setForeground(new java.awt.Color(204, 0, 0));
      timeDisplay.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      timeDisplay.setText("00:00:00");

      javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
      jPanel1.setLayout(jPanel1Layout);
      jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(timeDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE).addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE));
      jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(timeDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE).addContainerGap()));

      jPanel2.setBackground(new java.awt.Color(0, 0, 0));
      modeDisplay.setBackground(new java.awt.Color(255, 255, 255));
      modeDisplay.setEditable(false);
      modeDisplay.setFont(new java.awt.Font("Tahoma", 1, 12));
      modeDisplay.setHorizontalAlignment(javax.swing.JTextField.CENTER);

      javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
      jPanel2.setLayout(jPanel2Layout);
      jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout.createSequentialGroup().addGap(152, 152, 152).addComponent(modeDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(158, Short.MAX_VALUE)));
      jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(modeDisplay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE));

      jPanel3.setBackground(new java.awt.Color(255, 255, 255));
      modeButton.setBackground(new java.awt.Color(0, 0, 0));
      modeButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      modeButton.setForeground(new java.awt.Color(255, 255, 255));
      modeButton.setText("Mode");
      modeButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });

      okButton.setBackground(new java.awt.Color(0, 0, 0));
      okButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      okButton.setForeground(new java.awt.Color(255, 255, 255));
      okButton.setText("OK");
      okButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });
      okButton.addActionListener(alarmButtonSelectAction);

      hourButton.setBackground(new java.awt.Color(0, 0, 0));
      hourButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      hourButton.setForeground(new java.awt.Color(255, 255, 255));
      hourButton.setText("Hour");
      hourButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });
      hourButton.addActionListener(alarmButtonSelectAction);

      minutesButton.setBackground(new java.awt.Color(0, 0, 0));
      minutesButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      minutesButton.setForeground(new java.awt.Color(255, 255, 255));
      minutesButton.setText("Minutes");
      minutesButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });
      minutesButton.addActionListener(alarmButtonSelectAction);

      recordButton.setBackground(new java.awt.Color(0, 0, 0));
      recordButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      recordButton.setForeground(new java.awt.Color(255, 255, 255));
      recordButton.setText("Record");
      recordButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });

      playButton.setBackground(new java.awt.Color(0, 0, 0));
      playButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      playButton.setForeground(new java.awt.Color(255, 255, 255));
      playButton.setText("Play");
      playButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });

      fastButton.setBackground(new java.awt.Color(0, 0, 0));
      fastButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      fastButton.setForeground(new java.awt.Color(255, 255, 255));
      fastButton.setText("Fast");
      fastButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });

      stopButton.setBackground(new java.awt.Color(0, 0, 0));
      stopButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      stopButton.setForeground(new java.awt.Color(255, 255, 255));
      stopButton.setText("Stop");
      stopButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });

      upButton.setBackground(new java.awt.Color(0, 0, 0));
      upButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      upButton.setForeground(new java.awt.Color(255, 255, 255));
      upButton.setText("Up");
      upButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });
      upButton.addActionListener(alarmButtonSelectAction);

      downButton.setBackground(new java.awt.Color(0, 0, 0));
      downButton.setFont(new java.awt.Font("Tahoma", 1, 11));
      downButton.setForeground(new java.awt.Color(255, 255, 255));
      downButton.setText("Down");
      downButton.addActionListener(new java.awt.event.ActionListener()
      {
         public void actionPerformed(java.awt.event.ActionEvent evt)
         {
            event(evt);
         }
      });
      downButton.addActionListener(alarmButtonSelectAction);

      javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
      jPanel3.setLayout(jPanel3Layout);
      jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addComponent(modeButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(hourButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(recordButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(fastButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(upButton)).addGroup(jPanel3Layout.createSequentialGroup().addComponent(okButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(minutesButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(playButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(stopButton).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(downButton))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

      jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]{downButton, fastButton, hourButton, minutesButton, modeButton, okButton, playButton, recordButton, stopButton, upButton});

      jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(modeButton).addComponent(fastButton).addComponent(upButton).addComponent(recordButton).addComponent(hourButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE).addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(okButton).addComponent(minutesButton).addComponent(playButton).addComponent(stopButton).addComponent(downButton)).addGap(19, 19, 19)));

      jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[]{downButton, fastButton, minutesButton, modeButton, okButton, playButton, recordButton, stopButton, upButton});

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
      layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(14, 14, 14).addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
      pack();
   }// </editor-fold>                        


   private void event(java.awt.event.ActionEvent evt)
   {


      // TODO add your handling code here:
   }

   /**
    * @param args the command line arguments
    */
   public static void main(String args[])
   {
      java.awt.EventQueue.invokeLater(new Runnable()
      {
         public void run()
         {
            new GuiPanel().setVisible(true);
         }
      });
   }

   // Variables declaration - do not modify                    
   private javax.swing.JButton downButton;
   private javax.swing.JButton fastButton;
   private javax.swing.JButton hourButton;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JPanel jPanel2;
   private javax.swing.JPanel jPanel3;
   private javax.swing.JButton minutesButton;
   private javax.swing.JButton modeButton;
   private javax.swing.JTextField modeDisplay;
   private javax.swing.JButton okButton;
   private javax.swing.JButton playButton;
   private javax.swing.JButton recordButton;
   private javax.swing.JButton stopButton;
   private javax.swing.JLabel timeDisplay;
   private javax.swing.JButton upButton;
   private JLabel alarmTempDisplay;
   // End of variables declaration                  
   public javax.swing.JLabel getTimeDisplay()
   {
      return timeDisplay;
   }

   public void setTimeDisplay(javax.swing.JLabel timeDisplay)
   {
      this.timeDisplay = timeDisplay;
   }


   /**
    * @param prn
    */
   public void setDispProvider(DispTime prn)
   {
      dispProv = prn;
   }

   private DispTime dispProv;

}
I'd suggest using a set of Radio buttons, or a JComboBox to allow the user to select mode
I hate java layout, I'm going to bed talk with you next time. thanks for all the help.
JComboBox solves some of the layout issues (as you only have a single control to place).
Also allows you to store Mode objects directly in model

pieces u would need would be:

// create your model, containing all your modes

private ComboBoxModel modes = new DefaultComboBoxModel(new Object[] {
   new ClockMode(),
   new AlarmMode(), .... });


// create a combo to display your modes, allowing user to change mode

JComboBox modes = new JComboBox(modes);

// add a listener to update label when mode changes

modes.addActionListener(new ModeLabelUpdater(modeLabel));

// add a method to return the current mode

public Mode getMode()
{
   return (Mode) modes.getSelectedItem();
}

// the listener class to update the label

public class ModeLabelUpdater implements ActionListener
{
   private JLabel label = null;

   private ModeLabelUpdater(JLabel label)
   {
      this.label = label;
   }

   public void actionPerformed(ActionEvent event)
   {
       label.setText(getMode().getLabel());
   }
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello objects you are not going to like this but i don't like the layout that i am coming up with. Either I stick with what I have or I am going to have to come up with a whole different GUI.  I don't really see the way it is as being a problem with people interfacing with. People are not that stupid. I have a plan for help that will make it very easy to learn to use.
There's absolutely no need to tear up your already working code. As it happens, the shortish case statement with enum is one of the more readable sections IMO ;-)
Hi CEHJ:  I wondered about this myself. I did like the idea of using different listeners for the different buttons, because i could get rid of some of the IF else statements. I would like so help to clean up the exisiting code. What do you think about using the listeners for the up, down, hour, minutes buttons because they do the same things always. I feel a little lost now about what to do. I don't want to use radioButton or combobox for the modes, I think the mode button with the OK button is fine. I like the way the GUI looks now. Give me your feedback, I'm learning on this end and you guys are the teachers.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code you gave me was for the button Enabling, not for changing the hours and minutes of the time. If what is being looked at is just the text of the mode there isn't really anything happening really as it would be with a listener, So isn't this a pretty secure approach? I included the code you gave me below.
private class AdvanceModeAction extends javax.swing.AbstractAction
{
      public AdvanceModeAction(String name)
      {
            super(name);
      }

      public void actionPerformed(java.awt.event.ActionEvent e)
      {
            advanceMode();
            enableAllButtons();

            switch (currentMode)
            {
                  case Alarm:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        fastButton.setEnabled(false);
                        alarmTempDisplay = new JLabel(timeDisplay.getText());
                        alarmStarted = false;
                        dispProv.setDispListener(alarmTempDisplay);
                        break;

                  case Audio:
                        hourButton.setEnabled(false);
                        minutesButton.setEnabled(false);
                        break;

                  case Clock:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Date:
                        recordButton.setEnabled(false);
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        break;

                  case Timer:
                        recordButton.setEnabled(false);
                 stopButton.setText("Reset");
                fastButton.setEnabled(true);  // changes like these
                fastButton.setText("Reset");  // changes like these
                        playButton.setEnabled(false);
                        stopButton.setEnabled(false);
                        dispProv.setDispListener(timeDisplay);
                        break;
                        dispProv.setDispListener(timeDisplay);
                        break;
            }
      }
}

If you look at the code in the question it is looking at the text of the current mode. If I used a listener for the hourButton, minutesButton, upButton and DownButton events then I could get rid of some of the If and else statements and wouldn't that make the code more readable as well? It is important to me that i approach this project with as much consciousness and awareness as possible. This way i am doing in action what is the right way to approach object programing. I already approached the beginning of the project from object modeling from my understanding of it, which came from the book "Beginning Java Objects from concepts to code" So even my layout of the GUI came from me trying to be in the users point of view. I don't want to waste anybodies time or energy here at E.E. but i also want to be able to draw upon you experience as a collective, not any individual here. I know that everyone has their own approach to things but to be set upon any direction is to cut ourselves off from learning. I want all of you that help me with this project to be present and real with what you feel and why in your communication in the threads we are in. This will help expand my understanding in the real world of code writing which will help me to be able to think in ways that i might not be able to if i hadn't went through these experiences with you. So please help me in what i am trying to do and support me to be a good programmer.
An if and a switch are the same thing :-D
suggestion to use a JComboBox was just for your interest as you appeared to be struggling with layouts, and a combo can greatluy simplify a guis layout.
Where you need work is in you gui's wiring, how it looks to the user is up to u :)

You still haven't explained what gui elements you are using to allow user to change mode. Let me that and I'll show you how best to wire it up.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am a little lost with what to do with this question. We have cover things that are not in this question, how should I handle this? I raised the points to 500 because of so many answers. Give me your feedback OK.
split between all involved and start a new question for any specific questions you have.
objects: what is meant here, please exlain it, i have looked but can't find anything that explains it to be. I know what a source file is it is the written code in a file uncompiled..

CEHJ:To ensure accessibility it would probably be better to compile
 public  enum Mode {
        Clock, Date, Alarm, Timer, Audio, Custom,
    }

in its own source files
He's saying put the enum in its own file, but as I've explained you don't even need an enum. It just results in a proliferation of if/switch statements and offers no real benefits.
That was what I thought but it said it didn't need tobe wrapped in a class because it was a class. But I didn't see any other way to compile it. I want to know how to handle this now that it has come to my awareness.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
objects:

I am finally getting what you mean about the use of listeners. I see that if a different listener is with each mode the action of the button changes as well because it is dealing with another listener. That was what i was having trouble getting.  They are different actions because the relationship with the mode is different. I sure hope i got it. This keeps the code simple and very readable as long as you make the names of your listeners clear. This was a little more advanced then for a beginner i think, am i right? I enjoy working with you, I will learn  what is important from you which will have a big impact on me being able to write good code. Thanks for all you help and time, it is much appreciated. By the way my name is Christopher
:-)