After compiling this code, I am getting a "cannot find symbol constructor Timer(int,Morning)" on line 17.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Morning extends JFrame
{
  private EasySound rooster;
  private int time;

  /**
   *   Constructor
   */

  public Morning (int time)
  {
  	time = 0;
  	Timer clock = new Timer(30, this);
  	clock.start();
  }
  
  public Morning()
  {
  	super("Morning");
    rooster = new EasySound("roost.wav");
    rooster.play();

    Container c = getContentPane();
    c.setBackground(Color.WHITE);
  }

  public static void main(String[] args)
  {
    Morning morning = new Morning();
    morning.setSize(300, 150);
    morning.setDefaultCloseOperation(EXIT_ON_CLOSE);
    morning.setVisible(true);
  }
}

Because the class "Timer" constructor prototype doesn't have the type you are declaring. Where is your Timer class? And what are its constructors?

// do you have this type of constructor in your Timer class?
public Timer(int anInt, Morning aMonringObj) {
 ...
}

The second parameter to the Timer constructor you're using needs to implement ActionListener . JFrame doesn't implement it, so you'll have to do that in your Morning class yourself.

Also: You'll get better results posting questions like this in the Java forum.

The problem is, I don't know what to put in place of super("Morning"). Does anyone know what that means. -From our computer to yours- zach&kody

Which Timer class do you really want to use? Is it from javax.swing.Timer, java.util.Timer, or your own customized class? You may need to look at the classes' constructor. They are different.

By the way, implementing only ActionListener() inside the Morning class won't solve the whole problem if you still pass in the "Morning" class to the Timer as it is now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.