import java.awt.*;
import java.awt.event.*;//for specifying windows events
import javax.swing.*;
import java.lang.*;
public class FrontE implements ActionListener,Runnable
{
JTextField jav,it,c;
Frame f;
JButton Submit;
int aa,bb,cc,tot;
float avg;
FrontE()
{
f=new Frame("Progress Calculator");
JLabel l1=new JLabel("Enter the marks here:");
f.add(l1);
Panel p=new Panel();
Panel p1=new Panel();
JLabel java=new JLabel("Java");
jav=new JTextField(3);
System.out.println(" ");
JLabel itc=new JLabel("Information Theorey");
it=new JTextField(3);
JLabel cn=new JLabel("Computer Networks");
c=new JTextField(3);
aa=Integer.parseInt(jav.getText());
bb=Integer.parseInt(it.getText());
cc=Integer.parseInt(c.getText());
p.setLayout(new GridLayout(3,1));
p.add(java);
p.add(itc);
p.add(cn);
p.add(jav);
p.add(it);
p.add(c);
Submit=new JButton("Submit");
p.add(Submit);
p1.add(p);
f.add(p1,BorderLayout.CENTER);
f.setSize(500,300);
f.setVisible(true);
Submit.addActionListener(this);
Thread T=new Thread(this);
T.start();
}
public void run()
{
try{
tot=aa+bb+cc;
avg=tot/3;
}
catch(Exception e)
{
}
}
public void actionPerformed(ActionEvent ae) 
{

String str = ae.getActionCommand();


if(str.equals("Submit"))

{

f.setVisible(false);
JFrame f2=new JFrame("Result");
f2.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}}); 
JLabel Total=new JLabel("TOTAL:");
JLabel t=new JLabel(Float.toString(tot));
JLabel avv=new JLabel("AVERAGE");
JLabel av=new JLabel(Float.toString(avg));
f2.setLayout(new GridLayout(3,1));
f2.add(Total);
f2.add(t);
f2.add(avv);
f2.add(av);
f2.setSize(300,300);
f2.setVisible(true);
}
}
public static void main(String ar[])
{
new FrontE();
}
}

i am trying to implement a simple multithreaded program in java...this prog shows me 5 errors...all are "cannot find symbol" error..pls help me out..i have to submit this assignment tomorrow

Recommended Answers

All 6 Replies

What are the line numbers of those 5 errors, or do you expect us to guess?
"cannot fond symbol" usually means a mis-typed name, or trying to use a variable outside its scope.

G:\javaessentials>javac FrontEn.java
FrontEn.java:43: cannot find symbol
symbol : constructor Thread(FrontEn)
location: class Thread
Thread T=new Thread(this);
^
FrontEn.java:44: cannot find symbol
symbol : method start()
location: class Thread
T.start();
^
.\Thread.java:10: cannot find symbol
symbol : variable thread
location: class sampleThread
thread.sleep(5000);
^
.\Thread.java:25: cannot find symbol
symbol : constructor Thread(sampleThread)
location: class Thread
Thread T=new Thread(ct);
^
.\Thread.java:26: cannot find symbol
symbol : method start()
location: class Thread
T.start();
^
5 errors


->these are the errors tat i get...

sorry...am new to java

Do you have another file containing a class called Thread in your current diectory?

Do you have another file containing a class called Thread in your current diectory?

thanks a lot..u saved me...yeah
a txt doc called threadwas there...wen i deleted it....my prog worked :D thanks a lot ...

but now its not sshowin the total and average properly... jus givin 0.0 as the answer... :|

Without proper indenting and some meaningful variables names there's no way for anyone else to really understand your code. Put in loads of System.out.println statements to print out the values of important variables at key points in your code (work backwards from the point where you first know something has gone wrong). You will quite quickly find out exactly where things are going wrong, then you know what to fix.

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.