Results 1 to 5 of 5
Thread: Debugging: Cannot Find Symbol
- 11-20-2012, 03:06 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 20
- Rep Power
- 0
Debugging: Cannot Find Symbol
I am debugging some code and for the love of god can not figure out why Im getting this error. The code is:
The error is:PHP Code:// DebugThirteen1 // Creates a frame with a specified size // Twice as tall as wide import javax.swing.*; public class DebugThirteen1 extends JFrame { public DebugThirteen1(int size) { super("This is my frame"); size = 200; //Set size setSize(size, size * 2); setVisible(true); //Added this line to set frame to visible setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Missing period between JFrame and EXIT } public static void main(String[] args) { DebugThirteen1 frame = new DebugThirteen1(); //Missing word new } }
I cant figure out why this error is coming up.C:\Users\Tyler\Documents\School Work\CIS280\Project 9>javac DebugThirteen1.java
DebugThirteen1.java:17: cannot find symbol
symbol : constructor DebugThirteen1()
location: class DebugThirteen1
JFrame DebugThirteen1 = new DebugThirteen1(); //Missing word new
^
1 error
- 11-20-2012, 04:08 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Debugging: Cannot Find Symbol
You receive the error because you don't have a default constructor in you class. Default constructor is constructor without parameters. Because of this you can call the default constructor using the new operator to create an instance of that class.
In your class you only have a constructor that accept a single parameter with the integer type. That's mean when creating a new instance you have to call this constructor. You should do:
Instead of:Java Code:DebugThirteen1 frame = new DebugThirteen1(100);
Which will produce an error because the constructor is not available.Java Code:DebugThirteen1 frame = new DebugThirteen1();
Website: Learn Java by Examples
- 11-20-2012, 04:13 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 20
- Rep Power
- 0
Re: Debugging: Cannot Find Symbol
Thank you for the explanation. That makes sense. So how would I go about getting rid of the necessary int argument in my Main? Would I just move size to the class?
- 11-20-2012, 04:19 AM #4
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Debugging: Cannot Find Symbol
You can always provide a default constructor in your class. And then define the default size of the frame in this constructor. So when you create a new instance using default constructor it will always use the default frame size.
Website: Learn Java by Examples
- 11-20-2012, 04:21 AM #5
Member
- Join Date
- Oct 2012
- Posts
- 20
- Rep Power
- 0
Re: Debugging: Cannot Find Symbol
This is what I did so I only had to define size 1 time rather than through an argument as well.
PHP Code:// DebugThirteen1 // Creates a frame with a specified size // Twice as tall as wide import javax.swing.*; public class DebugThirteen1 extends JFrame { size = 200; //Set size public DebugThirteen1(int size) { super("This is my frame"); setSize(size, size * 2); setVisible(true); //Added this line to set frame to visible setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Missing period between JFrame and EXIT } public static void main(String[] args) { DebugThirteen1 frame = new DebugThirteen1(); //Missing word new } }
Similar Threads
-
Cannot find symbol
By Eleeist in forum New To JavaReplies: 5Last Post: 01-22-2012, 08:36 PM -
Cannot Find Symbol
By Promisha in forum New To JavaReplies: 10Last Post: 03-30-2011, 02:11 AM -
Can not find symbol ???
By AliceNewbie in forum New To JavaReplies: 1Last Post: 02-17-2010, 01:44 AM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks