Error while running
when i run a program
import java.awt.*;
public class GetFrameExample extends java.applet.Applet {
TextArea frameLog = new TextArea(10, 60);
Dialog dialog;
/** Builds the interface. */
public void init() {
add(frameLog);
add(new Button("Create Dialog"));
}
/** Creates a dialog in response to button press. */
public boolean action(Event evt, Object what) {
if (evt.target instanceof Button) {
dialog = new GetFrameDialog(this, getFrame(this), false);
dialog.resize(360, 120);
dialog.setBackground(Color.green);
dialog.setVisible(true);
//dialog.show();
//return true;
}
return super.action(evt, what);
}
public static Frame getFrame(Component comp) {
for (Component c = comp; c != null; c = c.getParent()) {
if (c instanceof Frame) {
return (Frame) c;
}
}
return null;
}
/** Enters frame information into the log. */
public void logFrame(String s) {
frameLog.appendText(s);
}
/** Finds the frame for the mouse-down target component. */
public boolean mouseDown(Event evt, int x, int y) {
Frame frame = getFrame((Component)evt.target);
logFrame("In applet, x = " + x + ", y = " + y
+ ", frame: " + frame.getClass() + "\n");
return true;
}
public void paint(Graphics g) {
g.setColor(Color.blue);
g.fillRect(0, 0, size().width, size().height);
}
}
class GetFrameDialog extends Dialog {
Button myButton;
GetFrameExample controller;
GetFrameDialog(GetFrameExample d, Frame f, boolean modal) {
super(f, modal);
setLayout(new FlowLayout());
controller = d;
myButton = new Button("Destroy Dialog");
add(myButton);
myButton.setBackground(Color.lightGray);
}
/** Destroys the dialog if a WINDOW_DESTROY event is received. */
public boolean handleEvent(Event evt) {
if (evt.id == Event.WINDOW_DESTROY) {
this.dispose();
return true;
}
return super.handleEvent(evt);
}
/** Dismisses this dialog when the dismiss button is pressed. */
public boolean action(Event evt, Object what) {
if (evt.target instanceof Button) {
this.dispose();
return true;
}
return super.action(evt, what);
}
/** Finds the frame for the mouse-down target component. */
public boolean mouseDown(Event evt, int x, int y) {
Frame frame = GetFrameExample.getFrame((Component)evt.target);
controller.logFrame("In dialog, x = " + x + ", y = " + y
+ ", frame: " + frame.getClass() + "\n");
return true;
}
}
this shows the error as
Note: C:\JAVA\MyPrograms\GetFrameExample.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Please help me to solve this.
Saumya

