| | |
Java Applet Help
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hey Everybody,
I'm making a Java applet and trying to post it online. Whenever I open the HTML page where the applet is, i get an error message.
Here's the website with the applet on it:
Applet Website Link
Thanks in advanced,
C++
I'm making a Java applet and trying to post it online. Whenever I open the HTML page where the applet is, i get an error message.
Here's the website with the applet on it:
Applet Website Link
Thanks in advanced,
C++
this is the buggy line
you need to remove the last slash
<applet code = "http://www.inquiryBio.com/quiz.class/" width = "400" height = "180"> Java Syntax (Toggle Plain Text)
<applet code = "http://www.inquiryBio.com/quiz.class" width = "400" height = "180">
srry 2 double post, but:
tonakai, it worked but the applet freezes on the last JOptionPane screen. Here's my code:
Can you help me?
Thanks in advanced for your help,
C++
tonakai, it worked but the applet freezes on the last JOptionPane screen. Here's my code:
Java Syntax (Toggle Plain Text)
import java.awt.Graphics; import javax.swing.*; import java.awt.*; public class quiz extends JApplet { double t; int corCount; String input1; String input2; String input3; String input4; String input5; String input6; String input7; String input8; String input9; String input10; public void init(){ try{ JOptionPane.showMessageDialog(null, "Welcome to the quiz.\n\n" + "For multiple choice questions, enter the best LETTER.\n" + "For true / false quetions, enter 'T' or 'F'.\n\n" + "This quiz consists of 10 questions.", "R E A D T H I S M E S S A G E !", JOptionPane.WARNING_MESSAGE); input1 = JOptionPane.showInputDialog(null, "True or False:\n" + "Cancer cells can mutilate and become resistent to\n" + "chemotherapy drugs.\n", "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input1.equals("T") || input1.equals("t")) { corCount++; } input2 = JOptionPane.showInputDialog(null, "Multiple Choice:\n" + "Ectoderm gives rise to which of the following:\n\n" + "A nerve+skin\n" + "B internal organs\n" + "C muscles and bone\n" + "D all of the above\n", "Multiple Choice", JOptionPane.INFORMATION_MESSAGE); if (input2.equals("A") || input2.equals("a")) { corCount++; } input3 = JOptionPane.showInputDialog(null, "True or False:\n" + "The hair-like structures covering the\n" + "paramicium are flagella.\n", "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input3.equals("F") || input3.equals("f")) { corCount++; } input4 = JOptionPane.showInputDialog(null, "True or False:\n" + "The chloroplast detects light in a euglena.\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input4.equals("F") || input4.equals("f")) { corCount++; } input5 = JOptionPane.showInputDialog(null, "Multiple Choice:\n" + "While cloning, a specialized cell nucleus is inserted into:\n\n" + "A another specialized cell\n" + "B a normal egg\n" + "C an egg that had its nucleus removed\n" + "D the uterus of a female\n", "Multiple Choice", JOptionPane.INFORMATION_MESSAGE); if (input5.equals("C") || input5.equals("c")) { corCount++; } input6 = JOptionPane.showInputDialog(null, "True or False:\n" + "100,000,000,000 neurons are in a piece of tissue the size of a grain of rice.\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input6.equals("F") || input6.equals("f")) { corCount++; } input7 = JOptionPane.showInputDialog(null, "True or False:\n" + "The PR is in the bottom of the bud of the hand.\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input7.equals("T") || input7.equals("t")) { corCount++; } input8 = JOptionPane.showInputDialog(null, "True or False:\n" + "The SRC gene is the key to determining gender.\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input8.equals("F") || input8.equals("f")) { corCount++; } input9 = JOptionPane.showInputDialog(null, "True or False:\n" + "Select the gene rules of pairing.\n\n" + "A T,C and A,G\n" + "B A,T and G,C\n" + "C T,G and A,C\n" + "D both b and c\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input9.equals("B") || input9.equals("b")) { corCount++; } input10 = JOptionPane.showInputDialog(null, "True or False:\n" + "Cells need glucose to construct new parts.\n" , "TRUE OR FALSE ('T' or 'F')", JOptionPane.INFORMATION_MESSAGE); if (input10.equals("T") || input10.equals("t")) { corCount++; } if (corCount >= 8) { JOptionPane.showMessageDialog(null, "\nNumber Correct: " + corCount + " / 10", "Congratulations!!!", JOptionPane.INFORMATION_MESSAGE); } else if (corCount >= 5) { JOptionPane.showMessageDialog(null, "\nNumber Correct: " + corCount + " / 10", "Better Luck Next Time...", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "\nNumber Correct: " + corCount + " / 10", "Go Back to Preschool", JOptionPane.INFORMATION_MESSAGE); } } catch(Exception e){ } } public void nothing(){ try{ //this method halts the program - does nothing, hence the name nothing } catch(Exception e3){ } } public void paint(Graphics g) { super.paint(g); try{ g.setFont(new Font("arial", Font.BOLD, 16)); g.drawString(" Q U I Z ! ! ! ", 115, 15); g.drawRoundRect(45, 30, 270, 20, 15, 15); g.setFont(new Font("arial", Font.BOLD + Font.ITALIC, 14)); g.drawString("Questions Correct: " + corCount + " out of 10", 50, 45); g.setFont(new Font("arial", Font.PLAIN, 12)); g.drawString("Your Input:", 155, 70); g.drawString("1.) " + input1 + " ", 10, 80); g.drawString("6.) " + input6 + " \n", 300, 80); g.drawString("2.) " + input2 + " ", 10, 100); g.drawString("7.) " + input7 + " \n", 300, 100); g.drawString("3.) " + input3 + " ", 10, 120); g.drawString("8.) " + input8 + " \n", 300, 120); g.drawString("4.) " + input4 + " ", 10, 140); g.drawString("9.) " + input9 + " \n", 300, 140); g.drawString("5.) " + input5 + " ", 10, 160); g.drawString("10.) " + input10 + " \n", 300, 160); String in = JOptionPane.showInputDialog(null, "Type \"answers\" to view the answers,\n" + "\"exit\" to exit, and \"ignore\" to ignore this message.", "Answers", JOptionPane.QUESTION_MESSAGE); if (in.equals("answers") || in.equals("ANSWERS")) { JOptionPane.showMessageDialog(null, "Answers (Correct Letter)\n\n" + "1.) Cancer cells can mutilate to become resistent to chemo ( T )\n\n" + "2.) Ectoderm gives rise to nerve and skin ( A )\n\n" + "3.) Hair structures are called cilia ( F )\n\n" + "4.) The eyespot detects light ( F )\n\n" + "5.) Cell nucleus is inserted into an cell without a nucleus ( C )\n\n" + "6.) 100,000 neurons in brain tissue are about the size of rice ( F )\n\n" + "7.) The PR is at the bottom of the hand bud ( T )\n\n" + "8.) The SRY gene is the key to determining gender ( F )\n\n" + "9.) A,T and G,C are the rules of pairing ( B )\n\n" + "10.) Cells need raw materials to construct new parts ( T )", "Answers", JOptionPane.WARNING_MESSAGE); nothing(); } else if (in.equals("exit") || in.equals("EXIT")) { System.exit(0); } else { nothing(); } } catch(Exception e2){ } } }
Can you help me?
Thanks in advanced for your help,
C++
well, i run your program and it crushes on my computer too(wow, its portable....) 
i think putting these code may cause it, but i am not sure
in your "paint" method, because it not totally inyour hand at when it is going to called. so putting selections it not a good way in paint method, paint method needs to be fast, i think
move it somewhere else
and using an array string makes your code shorter....
see ya,

i think putting these code may cause it, but i am not sure
Java Syntax (Toggle Plain Text)
String in = JOptionPane.showInputDialog(null, "Type \"answers\" to view the answers,\n" + "\"exit\" to exit, and \"ignore\" to ignore this message.", "Answers", JOptionPane.QUESTION_MESSAGE);
move it somewhere else

and using an array string makes your code shorter....
see ya,
thank u for responding. I don't think having some JOptionPane statements in the paint method is the main problem. I think that ur correct, and it has to do with the JOptionPane u pointed out. I tried making another method - but i get the same result.
More help would be appreciated

server crash, thanks. the website's for science class (u probably figured that out). My teacher's paying for it
Do you have any suggestions
More help would be appreciated

server crash, thanks. the website's for science class (u probably figured that out). My teacher's paying for it
Do you have any suggestions well then, i must insist that it is what causes the bug. every time applet tries to paint itself, it just re-ask you the same question... putting things like JOptionsPane is still not a good idea i think,
but you can create a first time flag, which when you start to program, initilize it to false, then before you display your Joptionpane in paint method check if it is false, if false then display the JOptionPane and make it true... but it is a poor solution.
but you can create a first time flag, which when you start to program, initilize it to false, then before you display your Joptionpane in paint method check if it is false, if false then display the JOptionPane and make it true... but it is a poor solution.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by C++
server crash, thanks. the website's for science class (u probably figured that out). My teacher's paying for itDo you have any suggestions
![]() |
Similar Threads
- download java applet (Java)
- java applet (Java)
- Can I run an ASP file from a Java Applet Button? (Java)
- Java Applet [Move Image] (Java)
- Java applet failed (Java)
- calling the internet browser from a java applet (Java)
- Graph??? Help For My Project-java Applet (Java)
- where to get the java applet? (Web Browsers)
Other Threads in the Java Forum
- Previous Thread: How DO you count Upper Case letters?
- Next Thread: need help with java program
Views: 4592 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation awt binary bluetooth businessintelligence busy_handler(null) card chat class classes client code collision component constructor database draw eclipse error event eventlistener exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me jar java javafx javamicroeditionuseofmotionsensor javaprojects jmf jni jpanel jtree julia link linux list loop machine map method methods mobile netbeans newbie nls number object oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms socket sort sortedmaps sql string swing test textfield threads time transfer tree unlimited webservices windows






