I tried to compile this applet, but produce error:
C:\628>javac ResizeMe.java
Note: ResizeMe.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
C:\628>appletviewer ResizeMe.java
C:\628>javac -deprecation ResizeMe.java
ResizeMe.java:15: warning: size() in java.awt.Component has been deprecated
d = size();
^
ResizeMe.java:22: warning: mouseUp(java.awt.Event,int,int) in
java.awt.Component
has been deprecated
public boolean mouseUp(java.awt.Event evt, int x, int y) {
^
2 warnings
========================================
/*
* <applet code="ResizeMe" width=200 height=200></applet>
*/
import java.awt.*;
import java.applet.*;
public class ResizeMe extends Applet {
final int inc = 25;
int max = 500;
int min = 200;
Dimension d;
public void paint(Graphics g) {
d = size();
g.setColor(Color.black);
g.drawLine(0,0,d.width,d.height);
g.drawLine(0,d.width,d.height,0);
g.drawString(d.width + " x " + d.height, 10, 20);
}
public boolean mouseUp(java.awt.Event evt, int x, int y) {
int w = (d.width+ inc)>max?min:(d.width+inc);
int h = (d.height+ inc)>max?min:(d.height+inc);
resize(w,h);
return true;
}
}