954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I got a note while compiling java program-"java uses or overrides a deprecated API"

Firstly,I used an option javac -deprecated javafilename.java and compiled.secondly i have run the program using java filename but cannot view any result.
can anybody help in this regard,ur help much appreciated
Thanks,
Shrini.

shrini
Newbie Poster
2 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

I'm assuming your using the command prompt.
If so, why not use an IDE?
Also, if you post your code, might be able to find problem.

cms271828
Junior Poster
123 posts since Oct 2006
Reputation Points: 20
Solved Threads: 4
 
I'm assuming your using the command prompt. If so, why not use an IDE? Also, if you post your code, might be able to find problem.



Thanks for the reply,here is the code got from internet but i am new to java ,so i dont know how to call the methods in this program through main class

//This applet draws a Bezier curve after user gives the control points
//The Bezier curve is redrawn when user clicks on and moves on of the
//control points
import java.awt.*;
import java.applet.Applet;
public class Bezier extends Applet {
Point[] coordlist; //the control points
int numpoints; //number of control points
Image offscreenImg; //used for double buffering
Graphics offscreenG;
double t; //the time interval
double k = .025; //time step value for drawing curve
int moveflag = 5; //flag to notify if user is moving a point
Button restart;
boolean poly = true; //flag to draw control polygon and points
Button polygon;
public void init() {
//Create coordinate list
coordlist = new Point[4];
numpoints = 0;
//Create offscreen buffer
offscreenImg = createImage(size().width,size().height);
offscreenG = offscreenImg.getGraphics();
//add buttons to screen
restart = new Button("Restart");
add(restart);
polygon = new Button("Polygon");
add(polygon);
}
//this method is called internally by repaint()
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
//prepare screen
setBackground(Color.white);
offscreenG.setColor(Color.black);
offscreenG.clearRect(0,0,size().width,size().height);
//Draw control points and polygon
if(poly) {
for(int i=0;i1 && i<(numpoints-1))
offscreenG.drawLine(coordlist[i].x,coordlist[i].y,
coordlist[i+1].x,coordlist[i+1].y);
}
}
//Calculate and draw bezier curve
if(numpoints == 4) {
double x1,x2,y1,y2;
x1 = coordlist[0].x;
y1 = coordlist[0].y;
for(t=k;t<=1+k;t+=k){
//use Berstein polynomials
x2=(coordlist[0].x+t*(-coordlist[0].x*3+t*(3*coordlist[0].x-
coordlist[0].x*t)))+t*(3*coordlist[1].x+t*(-6*coordlist[1].x+
coordlist[1].x*3*t))+t*t*(coordlist[2].x*3-coordlist[2].x*3*t)+
coordlist[3].x*t*t*t;
y2=(coordlist[0].y+t*(-coordlist[0].y*3+t*(3*coordlist[0].y-
coordlist[0].y*t)))+t*(3*coordlist[1].y+t*(-6*coordlist[1].y+
coordlist[1].y*3*t))+t*t*(coordlist[2].y*3-coordlist[2].y*3*t)+
coordlist[3].y*t*t*t;
//draw curve
offscreenG.drawLine((int)x1,(int)y1,(int)x2,(int)y2);
x1 = x2;
y1 = y2;
}
}
g.drawImage(offscreenImg,0,0,this);
}
//check if user presses either button
public boolean action(Event e, Object o) { if (e.target == restart) {
//start all over with no points
numpoints = 0;
repaint();
poly = true;
return true;
}
else if(e.target == polygon) {
if(poly)
poly = false;
else
poly = true;
repaint();
return true;
}
return false;
}
public boolean mouseDown(Event evt, int x, int y) { //Store point in array
Point point = new Point(x,y);
//if there are less than four points, add another one

if(numpoints < 4) {
coordlist[numpoints] = point;
numpoints++;
repaint();
}
//otherwise, check if user is trying to click on old point
else
for(int i=0;i

shrini
Newbie Poster
2 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 
If so, why not use an IDE?


Not everybody want to use IDE's and why....

Applet have be viewed in web browser or in AppletViewer, plus applet don't have main method

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

Yes thats right, if you use an IDE such as Netbeans 5.0 /5.5, or most other IDEs, you can view your applet easily.

One thing to point out (True of JApplets anyway) is that an instance of the applet is automatically created at runtime, so you don't need to instantiate the class throught the init() method, or through the main method (like you have done above... Bezier be = new Bezier(); ), besides main method is not necessary, and wouldn't be called initially like in an application.

cms271828
Junior Poster
123 posts since Oct 2006
Reputation Points: 20
Solved Threads: 4
 

Doesn't the compiler warning tell you what deprecated method you're trying to use? Or at least a line number? I'm not going to look through that spaghetti code, next time post your code inside code tags.

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 

also, applets do not use a main method like an application would.

Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
 
I'm assuming your using the command prompt. If so, why not use an IDE?

IDEs just delay the inevitable. Kids who never use anything but one are utterly lost when they even get a new version of that same IDE that has a few buttons in a different place.
When they have to work without one (which WILL happen) they're completely out of their league.

Do NOT start using an IDE until you can do it manually, and read that documentation (it's there for a reason).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You