applet not initialized

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 8
Reputation: neknek is an unknown quantity at this point 
Solved Threads: 0
neknek neknek is offline Offline
Newbie Poster

applet not initialized

 
0
  #1
Aug 8th, 2008
I compiled the code just fine. But It doesn't show on the webpage.
The error message is:

load: class C:\kenken\Xample1.class not found.
java.lang.ClassNotFoundException: C:.kenken.Xample1.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I tried using appletviewer but it says "applet not initialized".


Here is the code

  1. import java.applet.*;
  2. import javax.swing.*;
  3. import javax.swing.JOptionPane;
  4. import java.awt.*;
  5. import java.awt.event.*;
  6.  
  7. public class Xample1 extends Applet implements ActionListener, ItemListener
  8. {
  9. double otpay=0, gross=0, net=0, tax=0, sss=0, pagibig=0, med=0, tded=0;
  10.  
  11. Label lbl1 = new Label("Employee Number: ");
  12. Label lbl2 = new Label("Employee Name: ");
  13. Label lbl3 = new Label("No. of Hours Worked: ");
  14. Label lbl4 = new Label("Rate per Hour: ");
  15. Label lbl5 = new Label("Overtime Pay: ");
  16. Label lbl6 = new Label("Gross Pay: ");
  17. Label lbl7 = new Label("Deductions: ");
  18. Label lbl8 = new Label("Total Deductions: ");
  19.  
  20. TextField txt1 = new TextField(15);
  21. TextField txt2 = new TextField(15);
  22. TextField txt3 = new TextField(15);
  23. TextField txt4 = new TextField(15);
  24. TextField txt5 = new TextField(15);
  25. TextField txt6 = new TextField(15);
  26. TextField txt7 = new TextField(15);
  27. TextField txt8 = new TextField(15);
  28. TextField txt9 = new TextField(15);
  29. TextField txt10 = new TextField(15);
  30. TextField txt11 = new TextField(15);
  31. TextField txt12 = new TextField(15);
  32.  
  33. CheckboxGroup cbg = new CheckboxGroup();
  34. Checkbox ot = new Checkbox("OT",false,cbg);
  35.  
  36.  
  37. Button btnC1 = new Button("Compute 1");
  38. Button btnC2 = new Button("Compute 2");
  39. Button btnNet = new Button("Net Pay");
  40. Button btnOk = new Button("OK");
  41. Button btnClr = new Button("Clear");
  42.  
  43. Checkbox chk1 = new Checkbox("Tax");
  44. Checkbox chk2 = new Checkbox("SSS");
  45. Checkbox chk3 = new Checkbox("PagIbig");
  46. Checkbox chk4 = new Checkbox("Medicare");
  47.  
  48.  
  49. public void init()
  50. { add(lbl1); add(txt1); add(lbl2); add(txt2);
  51. add(lbl3); add(txt3); add(lbl4); add(txt4);
  52. add(lbl5); add(txt5); add(ot); add(lbl6); add(txt6);
  53. add(btnC1); add(lbl7); add(chk1); add(txt7);
  54. add(chk2); add(txt8); add(chk3); add(txt9);
  55. add(chk4); add(txt10); add(lbl8); add(txt11);
  56. add(btnC2);add(btnNet); add(txt12);
  57. add(btnOk); add(btnClr);
  58. txt5.setEnabled(false);
  59. txt6.setEnabled(false);
  60. txt7.setEnabled(false);
  61. txt8.setEnabled(false);
  62. txt9.setEnabled(false);
  63. txt10.setEnabled(false);
  64. txt11.setEnabled(false);
  65. txt12.setEnabled(false);
  66. btnOk.addActionListener(this);
  67. btnClr.addActionListener(this);
  68. btnC1.addActionListener(this);
  69. btnC2.addActionListener(this);
  70. btnNet.addActionListener(this);
  71. ot.addItemListener(this);
  72. chk1.addItemListener(this);
  73. chk2.addItemListener(this);
  74. chk3.addItemListener(this);
  75. chk4.addItemListener(this);
  76. }
  77.  
  78. public void actionPerformed(ActionEvent ae)
  79. {
  80. if(ae.getSource() == btnOk)
  81. {
  82. JOptionPane.showMessageDialog(null, "Employee Number: " + txt1.getText() + "\nEmployee Name: " + txt2.getText() + "\nGross Pay: " + String.valueOf(txt6.getText()) + "\nTotal Deductions: " + String.valueOf(txt11.getText()) + "\nNet Pay: " + String.valueOf(txt12.getText()), "Pay Slip", JOptionPane.INFORMATION_MESSAGE);
  83. }
  84. if(ae.getSource() == btnC1)
  85. { if (Double.parseDouble(txt3.getText()) > 40)
  86. { gross = (Double.parseDouble(txt4.getText()) * 40) + (Double.parseDouble(txt5.getText()));
  87. txt6.setText(String.valueOf(gross));
  88. }
  89. else
  90. { gross = (Double.parseDouble(txt4.getText()) * Double.parseDouble(txt3.getText()));
  91. txt6.setText(String.valueOf(gross));
  92. }
  93. }
  94. if(ae.getSource() == btnC2)
  95. { tded = tax + sss + pagibig + med;
  96. txt11.setText(String.valueOf(tded));
  97. }
  98. if(ae.getSource() == btnNet)
  99. { net = gross - tded;
  100. txt12.setText(String.valueOf(net));
  101. }
  102. if(ae.getSource() == btnClr)
  103. {
  104. txt1.setText("");//number
  105. txt2.setText("");//name
  106. txt3.setText("");//hrs. worked
  107. txt4.setText("");//rate per hr.
  108. txt5.setText("");//ot pay
  109. txt6.setText("");//gross pay
  110. txt7.setText("");//tax
  111. txt8.setText("");//sss
  112. txt9.setText("");//pagibig
  113. txt10.setText("");//medicare
  114. txt11.setText("");//total deductions
  115. txt12.setText("");//net pay
  116. ot.setState(false);
  117. chk1.setState(false);
  118. chk2.setState(false);
  119. chk3.setState(false);
  120. chk4.setState(false);
  121. txt1.requestFocus();
  122. }
  123. }
  124.  
  125. public void itemStateChanged(ItemEvent ie)
  126. {
  127. if(ot.getState() == true)
  128. { if (Double.parseDouble(txt3.getText()) > 40)
  129. { otpay = (Double.parseDouble(txt3.getText()) - 40) * (Double.parseDouble(txt4.getText())*1.5);
  130. txt5.setText(String.valueOf(otpay));
  131. }
  132. else
  133. { ot.setState(false);
  134. otpay = 0.00;
  135. txt5.setText(String.valueOf(otpay));
  136. }
  137. }
  138. if(chk1.getState() == true)
  139. { if(gross < 10000)
  140. tax = gross * 0.05;
  141. else if((gross >=10000) && (gross < 15000))
  142. tax = gross * 0.075;
  143. else if((gross >=15000) && (gross < 20000))
  144. tax = gross * 0.10;
  145. else if((gross >=20000) && (gross < 25000))
  146. tax = gross * 0.15;
  147. else if((gross >=25000) && (gross <= 30000))
  148. tax = gross * 0.20;
  149. else tax = gross * 0.25;
  150. txt7.setText(String.valueOf(tax));
  151. }
  152. if(chk2.getState() == true)
  153. { sss = gross * 0.025;
  154. txt8.setText(String.valueOf(sss));
  155. }
  156. if(chk3.getState() == true)
  157. { pagibig = gross * 0.02;
  158. txt9.setText(String.valueOf(pagibig));
  159. }
  160. if(chk4.getState() == true)
  161. { med = gross * 0.03;
  162. txt10.setText(String.valueOf(med));
  163. }
  164.  
  165. }
  166. }

And here is the html code
  1. <html>
  2.  
  3. <applet code="C:\kenken\Xample1.class" height=250 width=200></applet>
  4. </html>

I also tried to put the html file in the same folder so
  1. <html>
  2.  
  3. <applet code="Xample1.class" height=250 width=200></applet>
  4. </html>

but it also doesn't work. the same error message Xample1.class is not found.
But really, Xample.class is on that folder.
Please, I really need help. Thanks.
Last edited by neknek; Aug 8th, 2008 at 11:30 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 43
Reputation: sanzilla has a little shameless behaviour in the past 
Solved Threads: 3
sanzilla sanzilla is offline Offline
Unverified User

Re: applet not initialized

 
0
  #2
Aug 9th, 2008
I just run it on the netbeans , it is running !

anyway try again with ,
<applet code="./Xample1.class" height=250 width=200></applet>
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 8
Reputation: neknek is an unknown quantity at this point 
Solved Threads: 0
neknek neknek is offline Offline
Newbie Poster

Re: applet not initialized

 
0
  #3
Aug 9th, 2008
  1. <applet code="./Xample1.class" height=250 width=200></applet>
still doesn't work on me.

yay, thanks. at least I know it's running.
maybe i'll just try to run it in netbeans too.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1973 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC