Results 1 to 4 of 4
Thread: Please check my java applet
- 07-21-2008, 04:20 PM #1
Member
- Join Date
- Jul 2008
- Posts
- 2
- Rep Power
- 0
Please check my java applet
i don't understand why i am able to compile it but not to run it. Here's my code:
import javax.swing.*;
public class ASampleGUIProgram
{
public static void main(String[] args)
{
String appleString;
appleString = JOptionPane.showInputDialog("Enter number of apples:");
int appleCount;
appleCount = Integer.parseInt(appleString);
String orangeString;
orangeString = JOptionPane.showInputDialog("Enter number of oranges:");
int orangeCount;
orangeCount = Integer.parseInt(orangeString);
int totalFruitCount;
totalFruitCount = appleCount + orangeCount;
JOptionPane.showMessageDialog(null, "The total number of fruit = " + totalFruitCount);
System.exit(0);
}
}
and this is the html code:
<html>
<head>
<title>ASampleGUIProgram</title>
</head>
<body>
<center>
<H1 >Applet Title</H1>
<applet code="ASampleGUIProgram.class" width="200" height="200"> </applet>
</center>
</body>
</html>
please check it. thanks!!!
- 07-21-2008, 04:33 PM #2
Are there any error messages in the Java Console when you load the html into a browser? Copy and paste them here.
You need to read up on writing Applets:
Applets extend the Applet class
The main() method is NOT used.
System.exit(0); is NOT allowed in applets.
What you've written should be executed by:
java ASampleGUIProgram
- 07-22-2008, 11:39 AM #3
Member
- Join Date
- Jul 2008
- Posts
- 2
- Rep Power
- 0
hi
thanks! it did work just by running it using:
java ASampleGUIProgram
i just copied it from a book. anyway, how can you change it so that it will run the way i want it to be? That is by using the appletviewer command
- 07-22-2008, 04:33 PM #4
Similar Threads
-
Java Applet Help
By Nuluvius in forum New To JavaReplies: 0Last Post: 03-01-2008, 03:04 PM -
New to JAVA Applet
By kazitula in forum Java AppletsReplies: 2Last Post: 10-31-2007, 08:11 PM -
how to check available resources in java program
By lealea in forum New To JavaReplies: 3Last Post: 08-13-2007, 08:35 PM -
Java 3d in applet
By carl in forum Java AppletsReplies: 1Last Post: 08-06-2007, 05:55 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks