We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,594 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Error "cannot find symbol constructor"

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);
  }
}
4
Contributors
5
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
8
Views
zach&kody
Newbie Poster
17 posts since Feb 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

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) {
 ...
}
Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 376
Skill Endorsements: 17

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.

gusano79
Master Poster
708 posts since May 2004
Reputation Points: 193
Solved Threads: 110
Skill Endorsements: 6

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

zach&kody
Newbie Poster
17 posts since Feb 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

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.

Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 376
Skill Endorsements: 17

i love you zach

stevenwilson
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0780 seconds using 2.68MB