Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Applet

  Asked By: Hisham    Date: Aug 24    Category: Java    Views: 987
  

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;
}
}

Share: 

 

12 Answers Found

 
Answer #1    Answered By: Arthur Cole     Answered On: Aug 24

Check the version of JSDK and JRE you are using?
Spend sometime reading the API.

 
Answer #2    Answered By: Jim Williamson     Answered On: Aug 24

/*
* <applet code="ResizeMe" width="200" height="200"></applet>
*/
import java.awt.*;
import java.awt.event.*;
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 = getSize();
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 void processMouseEvent(MouseEvent evt) {
int w = (d.width+ inc)>max?min:(d.width+inc);
int h = (d.height+ inc)>max?min:(d.height+inc);
resize(w,h);
}
}

 
Answer #3    Answered By: Sherri Parker     Answered On: Aug 24

why's the difference??
because it stil use the older version
of Java??

 
Answer #4    Answered By: Rachel Barnes     Answered On: Aug 24

Based on the compiler errors feedbacks, your JSDK and
JRE using the newer version while the code were in the
older version. I picked out the offended statements
for you and Charles patiently inserted in your code
for you. Thanks Charles.

There is a way to compile  the older version with the
-D switch at the end of the compiler command as such
javac filename.java -D. But I prefer you to coding
with the current version or at least in the realm of
1.4.0.xx because the I/O classes are more improved
than previous version as in 1.3.0. As it a de facto
practice of software industry, the newer version
includes the bug patch of the previous one.

 
Answer #5    Answered By: Julio Morgan     Answered On: Aug 24

I would like to know the working of an applet  tag in the browser - like
how the applet gets stopped when the browser in minimised and how it
restarts etc.

 
Answer #6    Answered By: Opal Alexander     Answered On: Aug 24

i have a problem in watching applets in browser. when i write my applet  with sun
one studio (j2sdk 1.4.0_02), in the tools->advanced java(sun) option "use java2
v1.1.4.0_02 for applet (require restart)" created and i can see my applet in
browser easily. but when i change my IDE to JBuilder 2006 (jdk 1.5) my applets
don't open in browser and i can't see any option like that option in browser.(i
should to use jdk 1.4.2 or higher) what is the reason of this problem? and how
can i recover that?

 
Answer #7    Answered By: Coleman Smith     Answered On: Aug 24


The version of the JDK used by the browser must be greater than or equal
to the version you use to compile. Thus, if you compile  with JDK 1.5,
but your browser uses JDK 1.4.2, you will have compatibility issues.
Make sure your compiler version is lower than or equal to your browser
version. You should also advertise this to your users: "This applet
requires JDK 1.5 or above."

 
Answer #8    Answered By: Benny Torres     Answered On: Aug 24

how can i sure that my browser jdk version is higher or equal with
1.5? and if my jdk version is lower than 1.5, how can i change this
jdk version to 1.5 or higher?
when i open my applet  in browser i see this error  in java  console!
what is this means?
Error loading class: project.userpage
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: project.userpage
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/vm/loader/URLClassLoader.loadClass
at com/ms/applet/AppletPanel.securedClassLoad
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.processSentEvent
at com/ms/applet/AppletPanel.run
at java/lang/Thread.run

 
Answer #9    Answered By: Ulfah Hashmi     Answered On: Aug 24

In Firefox, click on Tools->Java Console. At the top of the page it
gives the JRE version number. I know there's something similar in the
other browsers.

What was the class  project.userpage compiled with? If this is a 3rd
party class, you'll have to find out from the manufacturer.

 
Answer #10    Answered By: Adaulfo Fischer     Answered On: Aug 24

i want to retrieve data from DB and send these to applet. but i have 2
questions: 1- how can i show data in applet?(i must using java
controls like label?) 2- height and width of applet  isn't fixed
(depend of number of data that i must shown) how can i set this from
code? if i don't place width and height of applet in applet tag, it's
change dynamically?

 
Answer #11    Answered By: Nicholas Wells     Answered On: Aug 24

can we add two applets
i.e i have one applet  that contains the Login information
and second applet contain the registration information my problem is
that i want to merge this two applet can it possbile in java

can we merge two applets

 
Answer #12    Answered By: Lily Brown     Answered On: Aug 24

We can merge the two applets. We can communicate between the two applets
using the applet  context.

AppletContext provides applets with methods such as getApplet(name),
getApplets(),getAudioClip, getImage, showDocument and showStatus().

www.velocityreviews.com/.../t145897-getting-two-java-applets-to-commun\
icate-with-each-other.html

 
Didn't find what you were looking for? Find more on Applet Or get search suggestion and latest updates.




Tagged: