Results 1 to 5 of 5
- 04-01-2010, 01:07 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
can anyone help me with this program iam new to java please
I have few programs that was not working and there were many errors in that program can anyone help me with it please and change my errors also
1.Adding text box to applet
import java.awt.*;
import java.applet.*;
public class text extends Applet
{
public void init()
{
TextField text1,text2;
text1=new TextField(8);
text2=new TextField(8);
add(text1);
add(text2);
}
public void paint(Graphics g)
{
int x=0,y=0,z=0;
String s1,s2,s3;
g.drawString("input a no in each",10,50);
{
s1=text getText();
x=Integer.parseInt(s1);
s2=text getText();
y=Integer.parseInt(s2);
}
{
z=x+y;
s3=String.valueOf(z)
g.drawString("the sum is",10,75);
g.drawString(s3,10,75);
}
public boolean action(Event ev,object ob)
}
repaint()
return true;
}
}
//<applet code="text.class" width=300 height=200></applet>
2.Animation program
import java.awt.*;
import java.applet.*;
public class ani extends Applet implements Runnable
{
Thread t;
int x=0;
int y=200;
int j=5,i=50,k=40;
public void start()
{
Thread t=new Thread(this);
t.start();
}
public void run()
{
try
{
while(x<300)
{
x=5;
Thread.sleep(75);
repaint(0,180,300,50);
if(x==296)
x=0;
}
}
catch(Exception e)
{
}
}
public void paint(Graphics g)
{
g.drawString("HAI",100,100);
g.drawString("VICKY",x,y);
}
}
< applet code="ani.class"width=300,height=200>< \applet>Last edited by vicky1; 04-01-2010 at 01:23 PM.
- 04-01-2010, 01:52 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
1. You need to put your code in code tags.
2. You need to actually say what the problem is...not just "it's not working, please fix".
- 04-01-2010, 04:31 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
errors
these are the errors in the 1st program
/tmp/jc_25905/text.java:19: ';' expected
s1=text getText();
^
/tmp/jc_25905/text.java:21: ';' expected
s2=text getText();
^
/tmp/jc_25905/text.java:27: ';' expected
g.drawString("the sum is",10,75);
^
/tmp/jc_25905/text.java:30: illegal start of expression
public boolean action(Event ev,object ob)
^
/tmp/jc_25905/text.java:31: ';' expected
}
^
/tmp/jc_25905/text.java:32: invalid method declaration; return type required
repaint()
^
/tmp/jc_25905/text.java:33: ';' expected
return true;
^
/tmp/jc_25905/text.java:35: 'class' or 'interface' expected
}
^
/tmp/jc_25905/text.java:39: 'class' or 'interface' expected
^
9 errors
- 04-01-2010, 04:34 PM #4
Member
- Join Date
- Apr 2010
- Posts
- 3
- Rep Power
- 0
these are the errors of 2 program
/tmp/jc_26378/animation.java:38: illegal character: \92
\\<\applet> ^ /tmp/jc_26378/animation.java:38: illegal character: \92 \\<\applet> ^ /tmp/jc_26378/animation.java:38: illegal character: \92 \\<\applet> ^ /tmp/jc_26378/animation.java:39: 'class' or 'interface' expected ^ 4 errors
- 04-06-2010, 11:06 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
execute java program within java program
By popey in forum New To JavaReplies: 2Last Post: 10-22-2009, 05:32 PM -
Run program from Java
By nenadm in forum Advanced JavaReplies: 4Last Post: 12-07-2008, 10:36 PM -
Java Program
By littleBean in forum New To JavaReplies: 7Last Post: 07-21-2008, 11:07 PM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks