Results 1 to 7 of 7
Thread: Timer problem
- 07-09-2012, 05:17 PM #1
Member
- Join Date
- May 2012
- Posts
- 17
- Rep Power
- 0
Timer problem
Why I can't create constructor(Timer) ?
Error says that this type constructor is undefined, but I can swear, that I saw exactly same constructor in book and Java API.Java Code:public class monster extends JPanel{ private BufferedImage monster; private int x; private int y; private Timer timer; final int TIME = 50; public monster(){ timer = new Timer(TIME, new timeListener()); x = 0; y = 0; try{ monster = ImageIO.read(new File("target.jpg")); }catch(IOException e){ } } public void paintComponent(Graphics g){ g.drawImage(monster,x,y,null); } private class timeListener implements ActionListener{ public void actionPerformed(ActionEvent arg0) { } } }
- 07-09-2012, 05:41 PM #2
Re: Timer problem
Please use standard naming conventions- class names start with an upper-case letter, methods and variables with a lower-case letter.
What kind of Timer is that? Which constructor are you trying to call? What kind of values are you passing into the constructor? What's your actual error message?How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-09-2012, 05:41 PM #3
Re: Timer problem
Also, when do you import the proper Timer class?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-09-2012, 05:45 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Timer problem
What is the full error you get and the line on which that error occurs?
Please do not ask for code as refusal often offends.
- 07-09-2012, 05:57 PM #5
Member
- Join Date
- May 2012
- Posts
- 17
- Rep Power
- 0
- 07-09-2012, 06:09 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: Timer problem
And in answer to Kevin?
What Timer class is that?Please do not ask for code as refusal often offends.
- 07-11-2012, 12:44 PM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
Similar Threads
-
Timer Problem
By ellias2007 in forum New To JavaReplies: 1Last Post: 10-20-2011, 10:04 PM -
Pac-Man in NetBeans- a Timer and jLabel/jPannel problem
By PR0PHET in forum New To JavaReplies: 15Last Post: 11-15-2010, 08:29 PM -
How to cancel an individual timer in spite of canceling whole timer
By Java Tip in forum java.utilReplies: 0Last Post: 04-04-2008, 02:46 PM -
Problem with timer in java
By paul in forum Advanced JavaReplies: 3Last Post: 07-26-2007, 10:18 AM -
problem with timer
By Marcus in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 05:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks